Skip to content

Commit c7d185d

Browse files
authored
[dart][dio] fix features of dart-dio generator (#15537)
1 parent d60b108 commit c7d185d

3 files changed

Lines changed: 104 additions & 63 deletions

File tree

docs/generators/dart-dio.md

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -143,67 +143,67 @@ These options may be applied as additional-properties (cli) or configOptions (pl
143143
### Client Modification Feature
144144
| Name | Supported | Defined By |
145145
| ---- | --------- | ---------- |
146-
|BasePath||ToolingExtension
147-
|Authorizations||ToolingExtension
148-
|UserAgent||ToolingExtension
146+
|BasePath||ToolingExtension
147+
|Authorizations||ToolingExtension
148+
|UserAgent||ToolingExtension
149149
|MockServer|✗|ToolingExtension
150150

151151
### Data Type Feature
152152
| Name | Supported | Defined By |
153153
| ---- | --------- | ---------- |
154154
|Custom|✗|OAS2,OAS3
155-
|Int32||OAS2,OAS3
156-
|Int64||OAS2,OAS3
157-
|Float||OAS2,OAS3
158-
|Double||OAS2,OAS3
159-
|Decimal||ToolingExtension
160-
|String||OAS2,OAS3
161-
|Byte||OAS2,OAS3
162-
|Binary||OAS2,OAS3
163-
|Boolean||OAS2,OAS3
164-
|Date||OAS2,OAS3
165-
|DateTime||OAS2,OAS3
166-
|Password||OAS2,OAS3
167-
|File||OAS2
155+
|Int32||OAS2,OAS3
156+
|Int64||OAS2,OAS3
157+
|Float||OAS2,OAS3
158+
|Double||OAS2,OAS3
159+
|Decimal||ToolingExtension
160+
|String||OAS2,OAS3
161+
|Byte||OAS2,OAS3
162+
|Binary||OAS2,OAS3
163+
|Boolean||OAS2,OAS3
164+
|Date||OAS2,OAS3
165+
|DateTime||OAS2,OAS3
166+
|Password||OAS2,OAS3
167+
|File||OAS2
168168
|Uuid||
169-
|Array||OAS2,OAS3
169+
|Array||OAS2,OAS3
170170
|Null|✗|OAS3
171171
|AnyType|✗|OAS2,OAS3
172-
|Object||OAS2,OAS3
173-
|Maps||ToolingExtension
174-
|CollectionFormat||OAS2
175-
|CollectionFormatMulti||OAS2
176-
|Enum||OAS2,OAS3
177-
|ArrayOfEnum||ToolingExtension
178-
|ArrayOfModel||ToolingExtension
179-
|ArrayOfCollectionOfPrimitives||ToolingExtension
180-
|ArrayOfCollectionOfModel||ToolingExtension
181-
|ArrayOfCollectionOfEnum||ToolingExtension
182-
|MapOfEnum||ToolingExtension
183-
|MapOfModel||ToolingExtension
184-
|MapOfCollectionOfPrimitives||ToolingExtension
185-
|MapOfCollectionOfModel||ToolingExtension
186-
|MapOfCollectionOfEnum||ToolingExtension
172+
|Object||OAS2,OAS3
173+
|Maps||ToolingExtension
174+
|CollectionFormat||OAS2
175+
|CollectionFormatMulti||OAS2
176+
|Enum||OAS2,OAS3
177+
|ArrayOfEnum||ToolingExtension
178+
|ArrayOfModel||ToolingExtension
179+
|ArrayOfCollectionOfPrimitives||ToolingExtension
180+
|ArrayOfCollectionOfModel||ToolingExtension
181+
|ArrayOfCollectionOfEnum||ToolingExtension
182+
|MapOfEnum||ToolingExtension
183+
|MapOfModel||ToolingExtension
184+
|MapOfCollectionOfPrimitives||ToolingExtension
185+
|MapOfCollectionOfModel||ToolingExtension
186+
|MapOfCollectionOfEnum||ToolingExtension
187187

188188
### Documentation Feature
189189
| Name | Supported | Defined By |
190190
| ---- | --------- | ---------- |
191-
|Readme||ToolingExtension
192-
|Model||ToolingExtension
193-
|Api||ToolingExtension
191+
|Readme||ToolingExtension
192+
|Model||ToolingExtension
193+
|Api||ToolingExtension
194194

195195
### Global Feature
196196
| Name | Supported | Defined By |
197197
| ---- | --------- | ---------- |
198-
|Host||OAS2,OAS3
199-
|BasePath||OAS2,OAS3
200-
|Info||OAS2,OAS3
198+
|Host||OAS2,OAS3
199+
|BasePath||OAS2,OAS3
200+
|Info||OAS2,OAS3
201201
|Schemes|✗|OAS2,OAS3
202-
|PartialSchemes||OAS2,OAS3
203-
|Consumes||OAS2
204-
|Produces||OAS2
205-
|ExternalDocumentation||OAS2,OAS3
206-
|Examples||OAS2,OAS3
202+
|PartialSchemes||OAS2,OAS3
203+
|Consumes||OAS2
204+
|Produces||OAS2
205+
|ExternalDocumentation||OAS2,OAS3
206+
|Examples||OAS2,OAS3
207207
|XMLStructureDefinitions|✗|OAS2,OAS3
208208
|MultiServer|✗|OAS3
209209
|ParameterizedServer|✗|OAS3
@@ -214,34 +214,34 @@ These options may be applied as additional-properties (cli) or configOptions (pl
214214
### Parameter Feature
215215
| Name | Supported | Defined By |
216216
| ---- | --------- | ---------- |
217-
|Path||OAS2,OAS3
218-
|Query||OAS2,OAS3
219-
|Header||OAS2,OAS3
220-
|Body||OAS2
221-
|FormUnencoded||OAS2
222-
|FormMultipart||OAS2
223-
|Cookie||OAS3
217+
|Path||OAS2,OAS3
218+
|Query||OAS2,OAS3
219+
|Header||OAS2,OAS3
220+
|Body||OAS2
221+
|FormUnencoded||OAS2
222+
|FormMultipart||OAS2
223+
|Cookie||OAS3
224224

225225
### Schema Support Feature
226226
| Name | Supported | Defined By |
227227
| ---- | --------- | ---------- |
228-
|Simple||OAS2,OAS3
229-
|Composite||OAS2,OAS3
230-
|Polymorphism||OAS2,OAS3
231-
|Union||OAS3
232-
|allOf||OAS2,OAS3
233-
|anyOf||OAS3
234-
|oneOf||OAS3
228+
|Simple||OAS2,OAS3
229+
|Composite||OAS2,OAS3
230+
|Polymorphism||OAS2,OAS3
231+
|Union||OAS3
232+
|allOf||OAS2,OAS3
233+
|anyOf||OAS3
234+
|oneOf||OAS3
235235
|not|✗|OAS3
236236

237237
### Security Feature
238238
| Name | Supported | Defined By |
239239
| ---- | --------- | ---------- |
240-
|BasicAuth||OAS2,OAS3
241-
|ApiKey||OAS2,OAS3
240+
|BasicAuth||OAS2,OAS3
241+
|ApiKey||OAS2,OAS3
242242
|OpenIDConnect|✗|OAS3
243-
|BearerToken||OAS3
244-
|OAuth2_Implicit||OAS2,OAS3
243+
|BearerToken||OAS3
244+
|OAuth2_Implicit||OAS2,OAS3
245245
|OAuth2_Password|✗|OAS2,OAS3
246246
|OAuth2_ClientCredentials|✗|OAS2,OAS3
247247
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
@@ -250,7 +250,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
250250
### Wire Format Feature
251251
| Name | Supported | Defined By |
252252
| ---- | --------- | ---------- |
253-
|JSON||OAS2,OAS3
253+
|JSON||OAS2,OAS3
254254
|XML|✗|OAS2,OAS3
255255
|PROTOBUF|✗|ToolingExtension
256256
|Custom|✗|OAS2,OAS3

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public DartDioClientCodegen() {
9292
SchemaSupportFeature.anyOf
9393
)
9494
);
95-
generatorMetadata = GeneratorMetadata.newBuilder()
95+
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
9696
.stability(Stability.STABLE)
9797
.build();
9898

modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/dio/DartDioClientCodegenTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,25 @@
1616

1717
package org.openapitools.codegen.dart.dio;
1818

19+
import org.openapitools.codegen.ClientOptInput;
1920
import org.openapitools.codegen.CodegenConstants;
21+
import org.openapitools.codegen.DefaultGenerator;
22+
import org.openapitools.codegen.Generator;
23+
import org.openapitools.codegen.TestUtils;
24+
import org.openapitools.codegen.config.CodegenConfigurator;
2025
import org.openapitools.codegen.languages.DartDioClientCodegen;
2126
import org.testng.Assert;
2227
import org.testng.annotations.Test;
2328

2429
import java.io.BufferedReader;
30+
import java.io.File;
2531
import java.io.FileInputStream;
32+
import java.io.IOException;
2633
import java.io.InputStreamReader;
2734
import java.nio.charset.StandardCharsets;
35+
import java.nio.file.Files;
36+
import java.nio.file.Path;
37+
import java.nio.file.Paths;
2838
import java.util.ArrayList;
2939
import java.util.List;
3040
import java.util.Locale;
@@ -40,6 +50,15 @@ public void testInitialConfigValues() throws Exception {
4050
Assert.assertTrue(codegen.isHideGenerationTimestamp());
4151
}
4252

53+
@Test
54+
public void testInitialFeatures() {
55+
final DartDioClientCodegen codegen = new DartDioClientCodegen();
56+
codegen.processOpts();
57+
58+
Assert.assertNotNull(codegen.getFeatureSet().getSecurityFeatures());
59+
Assert.assertFalse(codegen.getFeatureSet().getSecurityFeatures().isEmpty());
60+
}
61+
4362
@Test
4463
public void testSettersForConfigValues() throws Exception {
4564
final DartDioClientCodegen codegen = new DartDioClientCodegen();
@@ -82,4 +101,26 @@ public void testKeywords() {
82101
}
83102
}
84103

104+
@Test
105+
public void verifyDartDioGeneratorRuns() throws IOException {
106+
File output = Files.createTempDirectory("test").toFile();
107+
output.deleteOnExit();
108+
109+
final CodegenConfigurator configurator = new CodegenConfigurator()
110+
.setGeneratorName("dart-dio")
111+
.setGitUserId("my-user")
112+
.setGitRepoId("my-repo")
113+
.setPackageName("my-package")
114+
.setInputSpec("src/test/resources/3_0/petstore.yaml")
115+
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
116+
117+
ClientOptInput opts = configurator.toClientOptInput();
118+
119+
Generator generator = new DefaultGenerator().opts(opts);
120+
List<File> files = generator.generate();
121+
files.forEach(File::deleteOnExit);
122+
123+
TestUtils.ensureContainsFile(files, output, "README.md");
124+
TestUtils.ensureContainsFile(files, output, "lib/src/api.dart");
125+
}
85126
}

0 commit comments

Comments
 (0)