Skip to content

Commit 751ffad

Browse files
authored
[dart] Cleanup and OAS3 support (#8085)
* [dart] Cleanup and regnerate old/wrong tests and docs * docs path seems to be doc now in all dart generators * generated tests are very old and use wrong classes * [dart-dio] Improve formatting * [dart][dart-dio] Restructure tests to same layout * remove duplicate/old openapi sample for which there is no generation config * generate to `petstore_client_lib` for both generators * run generated tests as integration tests for dart2 even if empty - this makes it easier to find compile errors * [dart] Improve gitignore handling for Dart generators * globally ignore all dart related files that should not be commited * remove old ignores that are no longer valid * [dart][dart-dio] Add OAS3 generation and integration tests Dart2 doesn't compile, needs fixes. * [dart] Do not attempt to deserialize binary content from JSON fields Not sure if that case is ever relevant but for now there doesn't seem to be a better option. * [dart] Fix integration tests for OAS3 petstore Some POST operations now return 200 with content. * [dart] Generate Petstore Fake API but don't add to integration tests yet Explicitly not adding the new integration tests to the master POM. They do not work but having them allows for quickly iterating on open issues without breaking existing basic OAS2/OAS3 petstore examples. Instead they should be run manually until everything is fixed.
1 parent ed72843 commit 751ffad

File tree

623 files changed

+28653
-5846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

623 files changed

+28653
-5846
lines changed

.gitignore

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,15 @@ samples/client/petstore/erlang-proper/rebar.lock
234234
samples/server/petstore/erlang-server/_build/
235235
samples/server/petstore/erlang-server/rebar.lock
236236

237-
# dart
238-
samples/client/petstore/dart/petstore/packages
239-
samples/client/petstore/dart/flutter_petstore/test/packages
240-
samples/client/petstore/dart/petstore/test/packages
241-
**/.dart_tool
237+
# Dart
238+
**/dart*/**/.dart_tool
239+
**/dart*/**/.packages
240+
**/dart*/**/pubspec.lock
241+
# Dart dio
242+
**/dart*/**/*.g.dart
243+
# Dart jaguar
244+
**/dart*/**/*.jser.dart
245+
**/dart*/**/*.jretro.dart
242246

243247
# JS
244248
samples/client/petstore/javascript-es6/package-lock.json
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: dart-dio
2+
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/dart-dio
5+
additionalProperties:
6+
hideGenerationTimestamp: "true"

bin/configs/dart-dio.yaml renamed to bin/configs/dart-dio-petstore-client-lib-oas2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
generatorName: dart-dio
2-
outputDir: samples/client/petstore/dart-dio
2+
outputDir: samples/client/petstore/dart-dio/petstore_client_lib
33
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
44
templateDir: modules/openapi-generator/src/main/resources/dart-dio
55
additionalProperties:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: dart-dio
2+
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_client_lib
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/dart-dio
5+
additionalProperties:
6+
hideGenerationTimestamp: "true"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: dart
2+
outputDir: samples/openapi3/client/petstore/dart2/petstore_client_lib_fake
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/dart2
5+
additionalProperties:
6+
hideGenerationTimestamp: "true"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: dart
2+
outputDir: samples/openapi3/client/petstore/dart2/petstore_client_lib
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/dart2
5+
additionalProperties:
6+
hideGenerationTimestamp: "true"

modules/openapi-generator/src/main/resources/dart-dio/class.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builde
88
{{#vars}}
99
{{#description}}/* {{{description}}} */{{/description}}
1010
{{#isNullable}}
11-
@nullable
11+
@nullable
1212
{{/isNullable}}
1313
@BuiltValueField(wireName: r'{{baseName}}')
1414
{{#isEnum}}{{classname}}{{{nameInCamelCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}} get {{name}};
1515
{{#allowableValues}}
16-
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}
16+
{{#min}}// range from {{min}} to {{max}}{{/min}}//{{^min}} enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}
1717
{{/allowableValues}}
1818
{{/vars}}
1919

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{{#models}}
22
{{#model}}
33
{{#imports}}
4-
import '{{.}}';
4+
import '{{.}}';
55
{{/imports}}
6-
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
6+
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
77
{{/model}}
88
{{/models}}

modules/openapi-generator/src/main/resources/dart2/class.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ class {{{classname}}} {
152152
{{/items.isArray}}
153153
{{/isMap}}
154154
{{^isMap}}
155+
{{#isBinary}}
156+
{{{name}}}: null, // No support for decoding binary content from JSON
157+
{{/isBinary}}
158+
{{^isBinary}}
155159
{{{name}}}: {{{complexType}}}.fromJson(json['{{{baseName}}}']),
160+
{{/isBinary}}
156161
{{/isMap}}
157162
{{/isArray}}
158163
{{/complexType}}

0 commit comments

Comments
 (0)