Skip to content

Commit

Permalink
Merge branch 'OpenAPITools:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-rosset authored Oct 12, 2021
2 parents d58e4a2 + 80c3a0e commit 7cd305c
Show file tree
Hide file tree
Showing 387 changed files with 72 additions and 12,087 deletions.
10 changes: 0 additions & 10 deletions bin/configs/dart-petstore-json-serializable-client-lib-fake.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/generators/dart.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|pubLibrary|Library name in generated code| |null|
|pubName|Name in generated pubspec| |null|
|pubVersion|Version in generated pubspec| |null|
|serializationLibrary|Specify serialization library|<dl><dt>**native_serialization**</dt><dd>Use native serializer, backwards compatible</dd><dt>**json_serializable**</dt><dd>Use json_serializable. Experimental and subject to breaking changes without further notice</dd></dl>|native_serialization|
|serializationLibrary|Specify serialization library|<dl><dt>**native_serialization**</dt><dd>Use native serializer, backwards compatible</dd></dl>|native_serialization|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|Source folder for generated code| |null|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public CSharpNetCoreClientCodegen() {
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
this.optionalEmitDefaultValuesFlag);

addSwitch(CodegenConstants.OPTIONAL_CONDITIONAL_SERIALIZATION,
CodegenConstants.OPTIONAL_CONDITIONAL_SERIALIZATION_DESC,
this.conditionalSerialization);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class DartClientCodegen extends AbstractDartCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);

public static final String SERIALIZATION_LIBRARY_NATIVE = "native_serialization";
public static final String SERIALIZATION_LIBRARY_JSON_SERIALIZABLE = "json_serializable";

public DartClientCodegen() {
super();
Expand All @@ -43,7 +42,6 @@ public DartClientCodegen() {

final Map<String, String> serializationOptions = new HashMap<>();
serializationOptions.put(SERIALIZATION_LIBRARY_NATIVE, "Use native serializer, backwards compatible");
serializationOptions.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "Use json_serializable. Experimental and subject to breaking changes without further notice");
serializationLibrary.setEnum(serializationOptions);
cliOptions.add(serializationLibrary);
}
Expand Down Expand Up @@ -88,15 +86,7 @@ private void setSerializationLibrary() {
LOGGER.info("Using serialization library {}", serialization_library);

switch (serialization_library) {
case SERIALIZATION_LIBRARY_JSON_SERIALIZABLE:
additionalProperties.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "true");
// json_serializable requires build.yaml
supportingFiles.add(new SupportingFile("build.yaml.mustache",
"" /* main project dir */,
"build.yaml"));
break;

case SERIALIZATION_LIBRARY_NATIVE: // fall trough to default backwards compatible generator
case SERIALIZATION_LIBRARY_NATIVE: // fall through to default backwards compatible generator
default:
additionalProperties.put(SERIALIZATION_LIBRARY_NATIVE, "true");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ import javax.validation.Valid;
{{#performBeanValidation}}
import org.hibernate.validator.constraints.*;
{{/performBeanValidation}}
{{#discriminator}}
import {{invokerPackage}}.JSON;
{{/discriminator}}

{{#models}}
{{#model}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@
{{^isReadOnly}}
{{^required}}
{{#defaultValue}}
{{^conditionalSerialization}}
{{^vendorExtensions.x-csharp-value-type}}
// use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{{defaultValue}}};
{{/vendorExtensions.x-csharp-value-type}}
{{#vendorExtensions.x-csharp-value-type}}
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
{{/vendorExtensions.x-csharp-value-type}}
{{/conditionalSerialization}}
{{/defaultValue}}
{{^defaultValue}}
{{^conditionalSerialization}}
Expand Down
28 changes: 1 addition & 27 deletions modules/openapi-generator/src/main/resources/dart2/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,7 @@ class {{{classname}}} {
{{/isMap}}
{{^isMap}}
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}};
{{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}}
{{#isArray}}
{{#uniqueItems}}
return (json.decode(response.body) as List)
.map((i) => {{{returnBaseType}}}.fromJson(i))
.toSet();
{{/uniqueItems}}
{{^uniqueItems}}
return (json.decode(response.body) as List)
.map((i) => {{{returnBaseType}}}.fromJson(i))
.toList();
{{/uniqueItems}}
{{/isArray}}
{{^isArray}}
{{#isMap}}
return {{{returnType}}}.from(json.decode(response.body));
{{/isMap}}
{{^isMap}}
{{#returnTypeIsPrimitive}}
return response.body as {{{returnBaseType}}};
{{/returnTypeIsPrimitive}}
{{^returnTypeIsPrimitive}}
return {{{returnType}}}.fromJson(json.decode(response.body));
{{/returnTypeIsPrimitive}}
{{/isMap}}
{{/isArray}}
{{/json_serializable}}
{{/isMap}}{{/isArray}}{{/native_serialization}}
}
return Future<{{{returnType}}}>.value();
{{/returnType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class ApiClient {
case '{{{classname}}}':
{{#isEnum}}
{{#native_serialization}}return {{{classname}}}TypeTransformer().decode(value);{{/native_serialization}}
{{#json_serializable}} return _$enumDecode(_${{{classname}}}EnumMap, value);{{/json_serializable}}
{{/isEnum}}
{{^isEnum}}
return {{{classname}}}.fromJson(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ String parameterToString(dynamic value) {
{{#model}}
{{#isEnum}}
if (value is {{{classname}}}) {
{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}{{#json_serializable}} return value.toString();{{/json_serializable}}
{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}
}
{{/isEnum}}
{{/model}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import 'dart:io';

import 'package:http/http.dart';
import 'package:intl/intl.dart';
{{#json_serializable}}
import 'package:json_annotation/json_annotation.dart';
{{/json_serializable}}
import 'package:meta/meta.dart';

part 'api_client.dart';
Expand All @@ -26,9 +23,6 @@ part 'auth/http_bearer_auth.dart';
{{#models}}{{#model}}part 'model/{{{classFilename}}}.dart';
{{/model}}{{/models}}

{{#json_serializable}}
part 'api.g.dart';
{{/json_serializable}}
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
const _dateEpochMarker = 'epoch';
final _dateFormatter = DateFormat('yyyy-MM-dd');
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
{{#native_serialization}}
{{>serialization/native/native_enum}}
{{/native_serialization}}
{{#json_serializable}}
{{>serialization/json_serializable/json_serializable_enum}}
{{/json_serializable}}
{{/isEnum}}
{{^isEnum}}
{{#native_serialization}}
{{>serialization/native/native_class}}
{{/native_serialization}}
{{#json_serializable}}
{{>serialization/json_serializable/json_serializable_class}}
{{/json_serializable}}
{{/isEnum}}
{{/model}}
{{/models}}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,5 @@ dependencies:
http: '>=0.13.0 <0.14.0'
intl: '^0.17.0'
meta: '^1.1.8'
{{#json_serializable}}
json_annotation: '^3.1.1'{{/json_serializable}}
dev_dependencies:
test: '>=1.16.0 <1.18.0'
{{#json_serializable}}
build_runner: '^1.10.9'
json_serializable: '^3.5.1'{{/json_serializable}}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ class ObjectSerializer
if ($class === 'object') {
settype($data, 'array');
return $data;
} else if ($class === 'mixed') {
settype($data, gettype($data));
return $data;
}

if ($class === '\DateTime') {
Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,6 @@
<modules>
<module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
<module>samples/openapi3/client/petstore/dart2/petstore</module>
<!--<module>samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake</module>-->
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake</module>
<module>samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake</module>
</modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ protected Animal()
throw new ArgumentNullException("className is a required property for Animal and cannot be null");
}
this._ClassName = className;
// use default value if no "color" provided
this.Color = color ?? "red";
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public bool ShouldSerializePetType()
public ChildCatAllOf(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat)
{
this._Name = name;
this.PetType = petType;
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public partial class Foo : IEquatable<Foo>, IValidatableObject
/// <param name="bar">bar (default to &quot;bar&quot;).</param>
public Foo(string bar = "bar")
{
// use default value if no "bar" provided
this.Bar = bar ?? "bar";
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public bool ShouldSerializeStatus()
this._Quantity = quantity;
this._ShipDate = shipDate;
this._Status = status;
this.Complete = complete;
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.openapitools.client.JSON;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.openapitools.client.JSON;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.openapitools.client.JSON;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.openapitools.client.JSON;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.openapitools.client.JSON;


/**
Expand Down
Loading

0 comments on commit 7cd305c

Please sign in to comment.