Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
330526f
PoC json_serializable in dart-dio-next
MichaelMarner Jul 20, 2021
eef247d
Move build.yaml template into json_serializable dir
MichaelMarner Jul 26, 2021
acddd80
Undo implicit-dynamic change
MichaelMarner Jul 26, 2021
cabdbda
Fix automatic formatting
MichaelMarner Jul 27, 2021
2c5ef70
Treat non-required fields as nullable
MichaelMarner Oct 26, 2021
693227c
Make class properties final
MichaelMarner Oct 26, 2021
e1c9571
Fix error introduced by merging in master
MichaelMarner Oct 26, 2021
b35785c
Fix map creation when deserializing
MichaelMarner Oct 27, 2021
36f47e7
Exclude built files from analysis
MichaelMarner Oct 27, 2021
0feda9b
Add new dio import props
MichaelMarner Oct 27, 2021
dc34a8a
Fix broken merge
MichaelMarner Oct 27, 2021
237bdc4
Fix configuration of nullable properties
MichaelMarner Oct 29, 2021
5d4fa0f
Only add api_util import if using built value
MichaelMarner Nov 4, 2021
f336c78
Add config param to set properties as final
MichaelMarner Dec 2, 2021
a3ab5d2
Fix syntax error due to merge
MichaelMarner Apr 12, 2022
4f3f64f
Update to simplified dio configuration
MichaelMarner Apr 12, 2022
3a2cb03
Merge branch 'master' into dart-dio-next-json-serializable
MichaelMarner Apr 12, 2022
019084a
Add missing api constructor template
MichaelMarner Apr 12, 2022
d6af303
Merge branch 'dart-dio-next-json-serializable' of github.com:MichaelM…
MichaelMarner Apr 12, 2022
f9c7e21
Fix import for multipart files
MichaelMarner Apr 12, 2022
826b465
Fix inclusion of library deserialize template
MichaelMarner Apr 12, 2022
6d185a1
Update docs
MichaelMarner Apr 12, 2022
a78f410
Remove trailing newline from class
MichaelMarner Apr 12, 2022
8e8cb4f
Fix whitespace in generated templates
MichaelMarner Apr 12, 2022
a820c44
FIx built value generation problem caused by merge conflicts
MichaelMarner Apr 12, 2022
6e2a3ae
Escape dollar signs in strings
MichaelMarner Apr 13, 2022
de62845
Handle enums
MichaelMarner Apr 13, 2022
3c56734
Config for json_serializable sample
MichaelMarner Apr 13, 2022
4203144
Generate sample for json_serializable
MichaelMarner Apr 13, 2022
87608f7
Revert "Escape dollar signs in strings"
MichaelMarner Apr 13, 2022
4c41ddb
Use raw strings when dealing with enum values
MichaelMarner Apr 13, 2022
78f075a
Add json_serializable Maven module ind fix number based enums
kuhnroyal Apr 13, 2022
25eb6bc
Merge pull request #3 from kuhnroyal/dart-dio-next-json-serializable
MichaelMarner Apr 14, 2022
5006f9e
Update docs and fix wrong maven module
kuhnroyal Apr 14, 2022
76f2d2c
Merge remote-tracking branch 'OpenAPITools/master' into dart-dio-next…
kuhnroyal Apr 14, 2022
4080525
Merge pull request #4 from kuhnroyal/dart-dio-next-json-serializable
MichaelMarner Apr 21, 2022
67ec4ed
Merge remote-tracking branch 'upstream/master' into dart-dio-next-jso…
MichaelMarner Apr 27, 2022
a016b88
Update minimum dart sdk with json serializable
MichaelMarner Apr 27, 2022
b894e14
Use dart 2.14 when testing Dart samples
MichaelMarner Apr 27, 2022
cf5ceef
Update codegen to remove analysis errors in output
MichaelMarner Apr 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:{{pubName}}/{{pubName}}.dart';
void main() {
{{^isEnum}}
{{! Due to required vars without default value we can not create a full instance here }}
final instance = {{{classname}}}Builder();
// TODO add properties to the builder and call build()
{{#includeLibraryTemplate}}test_instance{{/includeLibraryTemplate}}
{{/isEnum}}

group({{{classname}}}, () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
final instance = {{{classname}}}Builder();
// TODO add properties to the builder and call build()
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum {{{classname}}} {
{{#description}}
/// {{{.}}}
{{/description}}
@JsonValue(r{{{value}}})
@JsonValue({{#isString}}r{{/isString}}{{{value}}})
{{{name}}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum parameter can have a value, so field FIELD_1 can be represented by field-1 and so field-1 must be mapped to FIELD_1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest commits have fixed up generation of enums, and I've used @JsonValue() to specify the enum values

{{/enumVars}}
{{/allowableValues}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
enum {{{ enumName }}} {
{{#allowableValues}}
{{#enumVars}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same mapping here

@JsonValue(r{{{value}}})
@JsonValue({{#isString}}r{{/isString}}{{{value}}})
{{{name}}},
{{/enumVars}}
{{/allowableValues}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
final {{{classname}}}? instance = /* {{{classname}}}(...) */ null;
// TODO add properties to the entity
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@
<modules>
<module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake</module>
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib-json_serializable</module>
</modules>
</profile>
<profile>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,57 @@ lib/src/model/tag.dart
lib/src/model/user.dart
lib/src/model/user_type.dart
pubspec.yaml
test/additional_properties_class_test.dart
test/animal_test.dart
test/another_fake_api_test.dart
test/api_response_test.dart
test/array_of_array_of_number_only_test.dart
test/array_of_number_only_test.dart
test/array_test_test.dart
test/capitalization_test.dart
test/cat_all_of_test.dart
test/cat_test.dart
test/category_test.dart
test/class_model_test.dart
test/default_api_test.dart
test/deprecated_object_test.dart
test/dog_all_of_test.dart
test/dog_test.dart
test/enum_arrays_test.dart
test/enum_test_test.dart
test/fake_api_test.dart
test/fake_classname_tags123_api_test.dart
test/file_schema_test_class_test.dart
test/foo_test.dart
test/format_test_test.dart
test/has_only_read_only_test.dart
test/health_check_result_test.dart
test/inline_response_default_test.dart
test/map_test_test.dart
test/mixed_properties_and_additional_properties_class_test.dart
test/model200_response_test.dart
test/model_client_test.dart
test/model_enum_class_test.dart
test/model_file_test.dart
test/model_list_test.dart
test/model_return_test.dart
test/name_test.dart
test/nullable_class_test.dart
test/number_only_test.dart
test/object_with_deprecated_fields_test.dart
test/order_test.dart
test/outer_composite_test.dart
test/outer_enum_default_value_test.dart
test/outer_enum_integer_default_value_test.dart
test/outer_enum_integer_test.dart
test/outer_enum_test.dart
test/outer_object_with_enum_property_test.dart
test/pet_api_test.dart
test/pet_test.dart
test/read_only_first_test.dart
test/special_model_name_test.dart
test/store_api_test.dart
test/tag_test.dart
test/user_api_test.dart
test/user_test.dart
test/user_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,22 @@ enum EnumTestEnumStringRequiredEnum {


enum EnumTestEnumIntegerEnum {
@JsonValue(r1)
@JsonValue(1)
number1,
@JsonValue(r-1)
@JsonValue(-1)
numberNegative1,
@JsonValue(r11184809)
@JsonValue(11184809)
unknownDefaultOpenApi,
}



enum EnumTestEnumNumberEnum {
@JsonValue(r'1.1')
@JsonValue('1.1')
number1Period1,
@JsonValue(r'-1.2')
@JsonValue('-1.2')
numberNegative1Period2,
@JsonValue(r'11184809')
@JsonValue('11184809')
unknownDefaultOpenApi,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import 'package:json_annotation/json_annotation.dart';


enum OuterEnumInteger {
@JsonValue(r0)
@JsonValue(0)
number0,
@JsonValue(r1)
@JsonValue(1)
number1,
@JsonValue(r2)
@JsonValue(2)
number2,
@JsonValue(r11184809)
@JsonValue(11184809)
unknownDefaultOpenApi,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import 'package:json_annotation/json_annotation.dart';


enum OuterEnumIntegerDefaultValue {
@JsonValue(r0)
@JsonValue(0)
number0,
@JsonValue(r1)
@JsonValue(1)
number1,
@JsonValue(r2)
@JsonValue(2)
number2,
@JsonValue(r11184809)
@JsonValue(11184809)
unknownDefaultOpenApi,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>DartDioNextPetstoreClientLibFakeJsonSerializableTests</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>DartDioNext Petstore Client Lib Fake Json Serializable</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>pub-get</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pub</executable>
<arguments>
<argument>get</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>pub-run-build-runner</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pub</executable>
<arguments>
<argument>run</argument>
<argument>build_runner</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>dart-analyze</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>dart</executable>
<arguments>
<argument>analyze</argument>
<argument>--fatal-infos</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>dart-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>dart</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for AdditionalPropertiesClass
void main() {
final instance = AdditionalPropertiesClassBuilder();
// TODO add properties to the builder and call build()
final AdditionalPropertiesClass? instance = /* AdditionalPropertiesClass(...) */ null;
// TODO add properties to the entity

group(AdditionalPropertiesClass, () {
// Map<String, String> mapProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for Animal
void main() {
final instance = AnimalBuilder();
// TODO add properties to the builder and call build()
final Animal? instance = /* Animal(...) */ null;
// TODO add properties to the entity

group(Animal, () {
// String className
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for ApiResponse
void main() {
final instance = ApiResponseBuilder();
// TODO add properties to the builder and call build()
final ApiResponse? instance = /* ApiResponse(...) */ null;
// TODO add properties to the entity

group(ApiResponse, () {
// int code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for ArrayOfArrayOfNumberOnly
void main() {
final instance = ArrayOfArrayOfNumberOnlyBuilder();
// TODO add properties to the builder and call build()
final ArrayOfArrayOfNumberOnly? instance = /* ArrayOfArrayOfNumberOnly(...) */ null;
// TODO add properties to the entity

group(ArrayOfArrayOfNumberOnly, () {
// List<List<num>> arrayArrayNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for ArrayOfNumberOnly
void main() {
final instance = ArrayOfNumberOnlyBuilder();
// TODO add properties to the builder and call build()
final ArrayOfNumberOnly? instance = /* ArrayOfNumberOnly(...) */ null;
// TODO add properties to the entity

group(ArrayOfNumberOnly, () {
// List<num> arrayNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for ArrayTest
void main() {
final instance = ArrayTestBuilder();
// TODO add properties to the builder and call build()
final ArrayTest? instance = /* ArrayTest(...) */ null;
// TODO add properties to the entity

group(ArrayTest, () {
// List<String> arrayOfString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:openapi/openapi.dart';

// tests for Capitalization
void main() {
final instance = CapitalizationBuilder();
// TODO add properties to the builder and call build()
final Capitalization? instance = /* Capitalization(...) */ null;
// TODO add properties to the entity

group(Capitalization, () {
// String smallCamel
Expand Down
Loading