diff --git a/bin/configs/dart-next-petstore-client.yaml b/bin/configs/dart-next-petstore-client.yaml
new file mode 100644
index 000000000000..527b6d0da43b
--- /dev/null
+++ b/bin/configs/dart-next-petstore-client.yaml
@@ -0,0 +1,19 @@
+generatorName: dart-next
+outputDir: samples/openapi3/client/petstore/dart/next
+inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/dart-next
+additionalProperties:
+ hideGenerationTimestamp: "true"
+ pubName: petstore_api
+nameMappings:
+ _type: $type
+ type_: type$
+parameterNameMappings:
+ _type: $type
+ type_: type$
+enumNameMappings:
+ s: LOWER_CASE_S
+ S: UPPER_CASE_S
+operationIdNameMappings:
+ getArrayOfEnums: getFakeArrayofenums
+ fakeHealthGet: getFakeHealth
\ No newline at end of file
diff --git a/docs/generators/dart-next.md b/docs/generators/dart-next.md
new file mode 100644
index 000000000000..dd0df76e5d6e
--- /dev/null
+++ b/docs/generators/dart-next.md
@@ -0,0 +1,258 @@
+---
+title: Documentation for the dart-next Generator
+---
+
+## METADATA
+
+| Property | Value | Notes |
+| -------- | ----- | ----- |
+| generator name | dart-next | pass this to the generate command after -g |
+| generator stability | EXPERIMENTAL | |
+| generator type | CLIENT | |
+| generator language | Java | |
+| generator default templating engine | mustache | |
+| helpTxt | Generates a dart-next client. | |
+
+## CONFIG OPTIONS
+These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
+
+| Option | Description | Values | Default |
+| ------ | ----------- | ------ | ------- |
+|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
+|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true|
+|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
+|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false|
+|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
+|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
+|pubAuthor|Author name in generated pubspec| |Author|
+|pubAuthorEmail|Email address of the author in generated pubspec| |author@homepage|
+|pubDescription|Description in generated pubspec| |OpenAPI API client|
+|pubHomepage|Homepage in generated pubspec| |homepage|
+|pubLibrary|Library name in generated code| |openapi.api|
+|pubName|Name in generated pubspec| |openapi|
+|pubPublishTo|Publish_to in generated pubspec| |null|
+|pubRepository|Repository in generated pubspec| |null|
+|pubVersion|Version in generated pubspec| |1.0.0|
+|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| |src|
+|useEnumExtension|Allow the 'x-enum-values' extension for enums| |false|
+
+## IMPORT MAPPING
+
+| Type/Alias | Imports |
+| ---------- | ------- |
+
+
+## INSTANTIATION TYPES
+
+| Type/Alias | Instantiated By |
+| ---------- | --------------- |
+
+
+## LANGUAGE PRIMITIVES
+
+
+
String
+
bool
+
double
+
int
+
num
+
+
+## RESERVED WORDS
+
+
+
abstract
+
as
+
assert
+
async
+
augment
+
await
+
base
+
break
+
case
+
catch
+
class
+
const
+
continue
+
covariant
+
default
+
deferred
+
do
+
dynamic
+
else
+
enum
+
export
+
extends
+
extension
+
external
+
factory
+
false
+
final
+
finally
+
for
+
function
+
get
+
hide
+
if
+
implements
+
import
+
in
+
inout
+
interface
+
is
+
late
+
library
+
mixin
+
native
+
new
+
null
+
of
+
on
+
operator
+
out
+
part
+
patch
+
required
+
rethrow
+
return
+
sealed
+
set
+
show
+
source
+
static
+
super
+
switch
+
sync
+
this
+
throw
+
true
+
try
+
typedef
+
var
+
void
+
when
+
while
+
with
+
yield
+
+
+## FEATURE SET
+
+
+### Client Modification Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasePath|✓|ToolingExtension
+|Authorizations|✗|ToolingExtension
+|UserAgent|✗|ToolingExtension
+|MockServer|✗|ToolingExtension
+
+### Data Type Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Custom|✓|OAS2,OAS3
+|Int32|✓|OAS2,OAS3
+|Int64|✓|OAS2,OAS3
+|Float|✓|OAS2,OAS3
+|Double|✓|OAS2,OAS3
+|Decimal|✓|ToolingExtension
+|String|✓|OAS2,OAS3
+|Byte|✓|OAS2,OAS3
+|Binary|✓|OAS2,OAS3
+|Boolean|✓|OAS2,OAS3
+|Date|✓|OAS2,OAS3
+|DateTime|✓|OAS2,OAS3
+|Password|✓|OAS2,OAS3
+|File|✓|OAS2
+|Uuid|✗|
+|Array|✓|OAS2,OAS3
+|Null|✗|OAS3
+|AnyType|✓|OAS2,OAS3
+|Object|✓|OAS2,OAS3
+|Maps|✓|ToolingExtension
+|CollectionFormat|✓|OAS2
+|CollectionFormatMulti|✓|OAS2
+|Enum|✓|OAS2,OAS3
+|ArrayOfEnum|✓|ToolingExtension
+|ArrayOfModel|✓|ToolingExtension
+|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
+|ArrayOfCollectionOfModel|✓|ToolingExtension
+|ArrayOfCollectionOfEnum|✓|ToolingExtension
+|MapOfEnum|✓|ToolingExtension
+|MapOfModel|✓|ToolingExtension
+|MapOfCollectionOfPrimitives|✓|ToolingExtension
+|MapOfCollectionOfModel|✓|ToolingExtension
+|MapOfCollectionOfEnum|✓|ToolingExtension
+
+### Documentation Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Readme|✓|ToolingExtension
+|Model|✓|ToolingExtension
+|Api|✓|ToolingExtension
+
+### Global Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Host|✓|OAS2,OAS3
+|BasePath|✓|OAS2,OAS3
+|Info|✓|OAS2,OAS3
+|Schemes|✗|OAS2,OAS3
+|PartialSchemes|✓|OAS2,OAS3
+|Consumes|✓|OAS2
+|Produces|✓|OAS2
+|ExternalDocumentation|✓|OAS2,OAS3
+|Examples|✓|OAS2,OAS3
+|XMLStructureDefinitions|✗|OAS2,OAS3
+|MultiServer|✗|OAS3
+|ParameterizedServer|✗|OAS3
+|ParameterStyling|✗|OAS3
+|Callbacks|✗|OAS3
+|LinkObjects|✗|OAS3
+
+### Parameter Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Path|✓|OAS2,OAS3
+|Query|✓|OAS2,OAS3
+|Header|✓|OAS2,OAS3
+|Body|✓|OAS2
+|FormUnencoded|✓|OAS2
+|FormMultipart|✓|OAS2
+|Cookie|✓|OAS3
+
+### Schema Support Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|Simple|✓|OAS2,OAS3
+|Composite|✓|OAS2,OAS3
+|Polymorphism|✓|OAS2,OAS3
+|Union|✓|OAS3
+|allOf|✓|OAS2,OAS3
+|anyOf|✓|OAS3
+|oneOf|✓|OAS3
+|not|✗|OAS3
+
+### Security Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|BasicAuth|✓|OAS2,OAS3
+|ApiKey|✓|OAS2,OAS3
+|OpenIDConnect|✗|OAS3
+|BearerToken|✓|OAS3
+|OAuth2_Implicit|✓|OAS2,OAS3
+|OAuth2_Password|✗|OAS2,OAS3
+|OAuth2_ClientCredentials|✗|OAS2,OAS3
+|OAuth2_AuthorizationCode|✗|OAS2,OAS3
+|SignatureAuth|✗|OAS3
+|AWSV4Signature|✗|ToolingExtension
+
+### Wire Format Feature
+| Name | Supported | Defined By |
+| ---- | --------- | ---------- |
+|JSON|✓|OAS2,OAS3
+|XML|✓|OAS2,OAS3
+|PROTOBUF|✗|ToolingExtension
+|Custom|✓|OAS2,OAS3
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 434983fb5e06..755b1eb46475 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -553,7 +553,7 @@ public Map postProcessAllModels(Map objs)
private boolean codegenPropertyIsNew(CodegenModel model, CodegenProperty property) {
return model.parentModel == null
? false
- : model.parentModel.allVars.stream().anyMatch(p ->
+ : model.parentModel.allVars.stream().anyMatch(p ->
p.name.equals(property.name) &&
(p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false || p.isDiscriminator));
}
@@ -793,35 +793,35 @@ public ModelsMap postProcessModelsEnum(ModelsMap objs) {
// update codegen property enum with proper naming convention
// and handling of numbers, special characters
for (CodegenProperty var : cm.vars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.allVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.nonNullableVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.requiredVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.optionalVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.parentVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.readOnlyVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
for (CodegenProperty var : cm.readWriteVars) {
- updateCodegenPropertyEnum(var);
+ updateCodegenPropertyEnum(var,cm);
}
}
@@ -6694,6 +6694,17 @@ public void updateCodegenPropertyEnum(CodegenProperty var) {
}
}
+ /**
+ * Update codegen property's enum by adding "enumVars" (with name and value),
+ * This method also has access to the parent CodegenModel.
+ *
+ * @param var list of CodegenProperty
+ * @param model parent CodegenModel
+ */
+ public void updateCodegenPropertyEnum(CodegenProperty var, CodegenModel model) {
+ updateCodegenPropertyEnum(var);
+ }
+
protected String getEnumDefaultValue(String defaultValue, String dataType) {
final String enumDefaultValue;
if (isDataTypeString(dataType)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java
new file mode 100644
index 000000000000..a715a9fff09c
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java
@@ -0,0 +1,1340 @@
+package org.openapitools.codegen.languages;
+
+import static org.openapitools.codegen.CodegenConstants.SKIP_FORM_MODEL;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_CHAR;
+import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
+import static org.openapitools.codegen.utils.StringUtils.camelize;
+import static org.openapitools.codegen.utils.StringUtils.escape;
+import static org.openapitools.codegen.utils.StringUtils.underscore;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenModel;
+import org.openapitools.codegen.CodegenParameter;
+import org.openapitools.codegen.CodegenProperty;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.DefaultCodegen;
+import org.openapitools.codegen.SupportingFile;
+import org.openapitools.codegen.config.GlobalSettings;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.meta.features.ClientModificationFeature;
+import org.openapitools.codegen.meta.features.DataTypeFeature;
+import org.openapitools.codegen.meta.features.DocumentationFeature;
+import org.openapitools.codegen.meta.features.GlobalFeature;
+import org.openapitools.codegen.meta.features.ParameterFeature;
+import org.openapitools.codegen.meta.features.SchemaSupportFeature;
+import org.openapitools.codegen.meta.features.SecurityFeature;
+import org.openapitools.codegen.meta.features.WireFormatFeature;
+import org.openapitools.codegen.model.ModelMap;
+import org.openapitools.codegen.model.ModelsMap;
+import org.openapitools.codegen.model.OperationsMap;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Sets;
+import com.samskivert.mustache.DefaultCollector;
+import com.samskivert.mustache.Mustache;
+import com.samskivert.mustache.Mustache.Compiler;
+
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.parameters.Parameter;
+import lombok.Getter;
+import lombok.Setter;
+
+public class DartNextClientCodegen extends DefaultCodegen {
+ public static final String PROJECT_NAME = "projectName";
+
+ private final Logger LOGGER = LoggerFactory.getLogger(DartNextClientCodegen.class);
+
+ public static final String PUB_LIBRARY = "pubLibrary";
+ public static final String PUB_NAME = "pubName";
+ public static final String PUB_VERSION = "pubVersion";
+ public static final String PUB_DESCRIPTION = "pubDescription";
+ public static final String PUB_AUTHOR = "pubAuthor";
+ public static final String PUB_AUTHOR_EMAIL = "pubAuthorEmail";
+ public static final String PUB_HOMEPAGE = "pubHomepage";
+ public static final String PUB_REPOSITORY = "pubRepository";
+ public static final String PUB_PUBLISH_TO = "pubPublishTo";
+ public static final String USE_ENUM_EXTENSION = "useEnumExtension";
+ private static final String CLIENT_NAME = "clientName";
+
+ @Getter
+ @Setter
+ private String clientName;
+ @Setter
+ protected String pubLibrary = "openapi.api";
+ @Setter
+ protected String pubName = "openapi";
+ @Setter
+ protected String pubVersion = "1.0.0";
+ @Setter
+ protected String pubDescription = "OpenAPI API client";
+ @Setter
+ protected String pubAuthor = "Author";
+ @Setter
+ protected String pubAuthorEmail = "author@homepage";
+ @Setter
+ protected String pubHomepage = "homepage";
+ @Setter
+ protected String pubRepository = null;
+ @Setter
+ protected String pubPublishTo = null;
+ @Setter
+ protected boolean useEnumExtension = false;
+ @Setter
+ protected String sourceFolder = "src";
+ @Setter
+ protected boolean camelCaseDollarSign = false;
+
+ protected String libPath = "lib" + File.separator;
+
+ protected String srcPath() {
+ return libPath + sourceFolder + File.separator;
+ }
+
+ protected String testPath() {
+ return "test" + File.separator;
+ }
+
+ protected String modelsPath() {
+ return srcPath() + modelPackage();
+ }
+
+ protected String apisPath() {
+ return srcPath() + apiPackage();
+ }
+
+ protected String networkingPath() {
+ return srcPath() + "networking" + File.separator;
+ }
+
+ protected String serializationPath() {
+ return srcPath() + "serialization" + File.separator;
+ }
+
+ protected String apiDocFolder = "doc" + File.separator;
+ protected String modelDocFolder = "doc" + File.separator;
+ protected String apiTestFolder = "test" + File.separator + "apis" + File.separator;
+ protected String modelTestFolder = "test" + File.separator + "models" + File.separator;
+
+ protected Map imports = new HashMap<>();
+
+ public CodegenType getTag() {
+ return CodegenType.CLIENT;
+ }
+
+ public String getName() {
+ return "dart-next";
+ }
+
+ public String getHelp() {
+ return "Generates a dart-next client.";
+ }
+
+ public DartNextClientCodegen() {
+ super();
+
+ outputFolder = "generated-code" + File.separator + "dart-next";
+
+ embeddedTemplateDir = templateDir = "dart-next";
+ apiPackage = "apis";
+ modelPackage = "models";
+
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.EXPERIMENTAL)
+ .build();
+
+ supportsMixins = true;
+ supportsInheritance = true;
+ supportsMultipleInheritance = true;
+ legacyDiscriminatorBehavior = false;
+ supportsAdditionalPropertiesWithComposedSchema = true;
+ disallowAdditionalPropertiesIfNotPresent = false;
+ modifyFeatureSet(features -> features
+ .includeDataTypeFeatures(DataTypeFeature.AnyType, DataTypeFeature.Custom)
+ .includeDocumentationFeatures(DocumentationFeature.Readme)
+ .includeSchemaSupportFeatures(
+ SchemaSupportFeature.Polymorphism,
+ SchemaSupportFeature.Union,
+ SchemaSupportFeature.Composite,
+ SchemaSupportFeature.allOf,
+ SchemaSupportFeature.oneOf,
+ SchemaSupportFeature.anyOf)
+
+ .securityFeatures(EnumSet.of(
+ SecurityFeature.OAuth2_Implicit,
+ SecurityFeature.BasicAuth,
+ SecurityFeature.BearerToken,
+ SecurityFeature.ApiKey))
+ .excludeGlobalFeatures(
+ GlobalFeature.XMLStructureDefinitions,
+ GlobalFeature.Callbacks,
+ GlobalFeature.LinkObjects,
+ GlobalFeature.ParameterStyling)
+ .includeParameterFeatures(
+ ParameterFeature.Cookie)
+ .includeClientModificationFeatures(
+ ClientModificationFeature.BasePath)
+ .includeWireFormatFeatures(WireFormatFeature.Custom));
+
+ // modelDocTemplateFiles.put("object_doc.mustache", ".md");
+ // apiDocTemplateFiles.put("api_doc.mustache", ".md");
+
+ // modelTestTemplateFiles.put("model_test.mustache", ".dart");
+ // apiTestTemplateFiles.put("api_test.mustache", ".dart");
+
+ final List reservedWordsList = new ArrayList<>();
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
+ StandardCharsets.UTF_8))) {
+ while (reader.ready()) {
+ reservedWordsList.add(reader.readLine());
+ }
+ } catch (Exception e) {
+ LOGGER.error("Error reading dart keywords. Exception: {}", e.getMessage());
+ }
+ setReservedWordsLowerCase(reservedWordsList);
+
+ // These types return isPrimitive=true in templates
+ languageSpecificPrimitives = Sets.newHashSet(
+ "String",
+ "bool",
+ "int",
+ "num",
+ "double");
+
+ typeMapping = new HashMap<>();
+ typeMapping.put("Array", "List");
+ typeMapping.put("array", "List");
+ typeMapping.put("map", "Map");
+ typeMapping.put("List", "List");
+ typeMapping.put("set", "Set");
+ typeMapping.put("boolean", "bool");
+ typeMapping.put("string", "String");
+ typeMapping.put("char", "String");
+ typeMapping.put("int", "int");
+ typeMapping.put("long", "int");
+ typeMapping.put("short", "int");
+ typeMapping.put("number", "num");
+ typeMapping.put("float", "double");
+ typeMapping.put("double", "double");
+ typeMapping.put("decimal", "double");
+ typeMapping.put("integer", "int");
+ typeMapping.put("Date", "DateTime");
+ typeMapping.put("date", "DateTime");
+ typeMapping.put("DateTime", "DateTime");
+ typeMapping.put("file", "XFile");
+ typeMapping.put("binary", "Uint8List");
+ typeMapping.put("UUID", "String");
+ typeMapping.put("URI", "Uri");
+ typeMapping.put("ByteArray", "Uint8List");
+ typeMapping.put("object", "$FreeFormObject");
+ typeMapping.put("AnyType", "Object");
+
+ // Data types of the above values which are automatically imported
+ defaultIncludes = Sets.newHashSet(
+ "String",
+ "bool",
+ "int",
+ "num",
+ "double",
+ "List",
+ "Set",
+ "Map",
+ "DateTime",
+ "Object");
+
+ imports.put("String", "dart:core");
+ imports.put("bool", "dart:core");
+ imports.put("int", "dart:core");
+ imports.put("num", "dart:core");
+ imports.put("double", "dart:core");
+ imports.put("List", "dart:core");
+ imports.put("Set", "dart:core");
+ imports.put("Map", "dart:core");
+ imports.put("DateTime", "dart:core");
+ imports.put("Object", "dart:core");
+ // imports.put("MultipartFile", "package:http/http.dart");
+
+ addOption(PUB_LIBRARY, "Library name in generated code", pubLibrary);
+ addOption(PUB_NAME, "Name in generated pubspec", pubName);
+ addOption(PUB_VERSION, "Version in generated pubspec", pubVersion);
+ addOption(PUB_DESCRIPTION, "Description in generated pubspec", pubDescription);
+ addOption(PUB_AUTHOR, "Author name in generated pubspec", pubAuthor);
+ addOption(PUB_AUTHOR_EMAIL, "Email address of the author in generated pubspec", pubAuthorEmail);
+ addOption(PUB_HOMEPAGE, "Homepage in generated pubspec", pubHomepage);
+ addOption(PUB_REPOSITORY, "Repository in generated pubspec", pubRepository);
+ addOption(PUB_PUBLISH_TO, "Publish_to in generated pubspec", pubPublishTo);
+ addOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums",
+ String.valueOf(useEnumExtension));
+ addOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC, sourceFolder);
+ }
+
+ @Override
+ public Compiler processCompiler(Compiler compiler) {
+
+ // see https://github.com/samskivert/jmustache/issues/82#issuecomment-226284364
+ return super.processCompiler(compiler).withCollector(new DefaultCollector() {
+ @Override
+ public Mustache.VariableFetcher createFetcher(Object ctx, String name) {
+ if (ctx instanceof Map, ?> && name.equals("entrySet")) {
+ return new Mustache.VariableFetcher() {
+ public Object get(Object ctx, String name) throws Exception {
+ return ((Map, ?>) ctx).entrySet();
+ }
+ };
+ } else if (ctx instanceof Map.Entry, ?>) {
+ if (name.equals("key")) {
+ return new Mustache.VariableFetcher() {
+ public Object get(Object ctx, String name) throws Exception {
+ return ((Map.Entry, ?>) ctx).getKey();
+ }
+ };
+ } else if (name.equals("value")) {
+ return new Mustache.VariableFetcher() {
+ public Object get(Object ctx, String name) throws Exception {
+ return ((Map.Entry, ?>) ctx).getValue();
+ }
+ };
+ }
+ }
+ return super.createFetcher(ctx, name);
+ }
+ });
+ }
+
+ @Override
+ protected String toMediaTypeSchemaName(String contentType, String mediaTypeSchemaSuffix) {
+ contentType = contentType.replaceAll("\\*", "Any");
+ return toModelName(contentType);
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+ allowUnicodeIdentifiers = true;
+
+ // Since we generate models for apis anyway, we need to always enable this.
+ GlobalSettings.setProperty(SKIP_FORM_MODEL, "false");
+
+ // Fix a couple Java notation properties
+ modelPackage = modelPackage.replace('.', '/');
+ apiPackage = apiPackage.replace('.', '/');
+ // And overwrite them in the additional properties
+ additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
+ additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
+
+ if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
+ LOGGER.info(
+ "Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"dart format\"` (Linux/Mac)");
+ LOGGER.info(
+ "NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
+ }
+
+ if (additionalProperties.containsKey(PUB_NAME)) {
+ this.setPubName((String) additionalProperties.get(PUB_NAME));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_NAME, pubName);
+ }
+
+ if (additionalProperties.containsKey(PUB_LIBRARY)) {
+ this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_LIBRARY, pubLibrary);
+ }
+
+ if (additionalProperties.containsKey(PUB_VERSION)) {
+ this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_VERSION, pubVersion);
+ }
+
+ if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
+ this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_DESCRIPTION, pubDescription);
+ }
+
+ if (additionalProperties.containsKey(PUB_AUTHOR)) {
+ this.setPubAuthor((String) additionalProperties.get(PUB_AUTHOR));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_AUTHOR, pubAuthor);
+ }
+
+ if (additionalProperties.containsKey(PUB_AUTHOR_EMAIL)) {
+ this.setPubAuthorEmail((String) additionalProperties.get(PUB_AUTHOR_EMAIL));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_AUTHOR_EMAIL, pubAuthorEmail);
+ }
+
+ if (additionalProperties.containsKey(PUB_HOMEPAGE)) {
+ this.setPubHomepage((String) additionalProperties.get(PUB_HOMEPAGE));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_HOMEPAGE, pubHomepage);
+ }
+
+ if (additionalProperties.containsKey(PUB_REPOSITORY)) {
+ this.setPubRepository((String) additionalProperties.get(PUB_REPOSITORY));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_REPOSITORY, pubRepository);
+ }
+
+ if (additionalProperties.containsKey(PUB_PUBLISH_TO)) {
+ this.setPubPublishTo((String) additionalProperties.get(PUB_PUBLISH_TO));
+ } else {
+ // not set, use to be passed to template
+ additionalProperties.put(PUB_PUBLISH_TO, pubPublishTo);
+ }
+
+ if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) {
+ this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION));
+ } else {
+ // Not set, use to be passed to template.
+ additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension);
+ }
+
+ if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
+ String srcFolder = (String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER);
+ this.setSourceFolder(srcFolder.replace('/', File.separatorChar));
+ }
+ additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
+
+ if (!additionalProperties.containsKey(CLIENT_NAME)) {
+ final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
+ additionalProperties.put(CLIENT_NAME, name);
+ LOGGER.debug("Client name not set, using default {}", name);
+ }
+ setClientName(additionalProperties.get(CLIENT_NAME).toString());
+
+ // make api and model doc path available in mustache template
+ additionalProperties.put("apiDocPath", apiDocFolder);
+ additionalProperties.put("modelDocPath", modelDocFolder);
+
+ // check to not overwrite a custom templateDir
+ if (templateDir == null) {
+ embeddedTemplateDir = templateDir = "dart-next";
+ }
+
+ String apisMustache = "lib/src/apis/";
+ String modelsMustache = "lib/src/models/";
+ String testsMustache = "test/";
+ String modelsTestsMustache = testsMustache + "models/";
+ String apisTestsMustache = testsMustache + "apis/";
+
+ modelTemplateFiles.put(modelsMustache + "model.mustache", ".dart");
+ modelTemplateFiles.put(modelsMustache + "model.reflection.mustache", ".reflection.dart");
+ // modelTemplateFiles.put(modelsMustache + "model.serialization.mustache", ".serialization.dart");
+
+ modelTestTemplateFiles.put(modelsTestsMustache + "model_tests.mustache", ".dart");
+ apiTestTemplateFiles.put(apisTestsMustache + "api_tests.mustache", ".dart");
+
+ apiTemplateFiles.put(apisMustache + "api.mustache", ".dart");
+ apiTemplateFiles.put(apisMustache + "api_requests.mustache", ".requests.dart");
+ apiTemplateFiles.put(apisMustache + "api_responses.mustache", ".responses.dart");
+
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md").doNotOverwrite());
+ supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml").doNotOverwrite());
+ supportingFiles.add(new SupportingFile("CHANGELOG.md", "", "CHANGELOG.md").doNotOverwrite());
+ supportingFiles.add(new SupportingFile("lib/internal_exports.mustache", "lib", "_internal.dart"));
+ supportingFiles.add(new SupportingFile("lib/public_exports.mustache", "lib", pubName + ".dart"));
+ supportingFiles.add(new SupportingFile("lib/src/facade.mustache", srcPath(), "api_facade.dart"));
+ supportingFiles.add(new SupportingFile(modelsMustache + "_exports.mustache", modelsPath(), "_exports.dart"));
+ supportingFiles.add(new SupportingFile(apisMustache + "_exports.mustache", apisPath(), "_exports.dart"));
+
+ supportingFiles.add(new SupportingFile(testsMustache + "utils.mustache", testPath(), "utils.dart"));
+
+ String networkingMustache = "lib/src/networking/";
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "_exports.mustache", networkingPath(), "_exports.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "_internal.mustache", networkingPath(), "_internal.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "helpers.mustache", networkingPath(), "helpers.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "property_encoding_rule.mustache", networkingPath(),
+ "property_encoding_rule.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "wire_serialization_options.mustache", networkingPath(),
+ "wire_serialization_options.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "multipart.mustache", networkingPath(), "multipart.dart"));
+ supportingFiles
+ .add(new SupportingFile(networkingMustache + "package_http_client.mustache", networkingPath(),
+ "package_http_client.dart"));
+ supportingFiles
+ .add(new SupportingFile(testsMustache + "networking/helpers_test.mustache",
+ testPath() + File.separator + "networking",
+ "helpers_test.dart"));
+
+ String serializationMustache = "lib/src/serialization/";
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "_exports.mustache", serializationPath(),
+ "_exports.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "_internal.mustache", serializationPath(),
+ "_internal.dart"));
+
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "additional_properties.mustache", serializationPath(),
+ "additional_properties.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "examples.mustache", serializationPath(),
+ "examples.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "open_api_object.mustache", serializationPath(),
+ "open_api_object.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "parameter_serialization.mustache", serializationPath(),
+ "parameter_serialization.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "json_extensions.mustache", serializationPath(),
+ "json_extensions.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "reflection.mustache", serializationPath(),
+ "reflection.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "model_reflection.mustache", serializationPath(),
+ "model_reflection.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "container_reflection.mustache", serializationPath(),
+ "container_reflection.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "generated_reflections.mustache", serializationPath(),
+ "generated_reflections.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "primitive_reflection.mustache", serializationPath(),
+ "primitive_reflection.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "context.mustache", serializationPath(),
+ "context.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "xml_extensions.mustache", serializationPath(),
+ "xml_extensions.dart"));
+ supportingFiles
+ .add(new SupportingFile(serializationMustache + "xml_reflection.mustache", serializationPath(),
+ "xml_reflection.dart"));
+ supportingFiles
+ .add(new SupportingFile(testsMustache + "serialization/helpers_test.mustache",
+ testPath() + File.separator + "serialization",
+ "helpers_test.dart"));
+ // TODO: add all files inside shared_infrastructure to root folder of generated
+ // addSharedInfrastructureFiles();
+ }
+
+ private final String kIsChild = "x-is-child";
+ private final String kIsParent = "x-is-parent";
+ private final String kIsPure = "x-is-pure";
+ private final String kSelfOnlyProps = "x-self-only-props";
+ private final String kHasSelfOnlyProps = "x-has-self-only-props";
+ private final String kAncestorOnlyProps = "x-ancestor-only-props";
+ private final String kHasAncestorOnlyProps = "x-has-ancestor-only-props";
+ private final String kSelfAndAncestorOnlyProps = "x-self-and-ancestor-only-props";
+ private final String kHasSelfAndAncestorOnlyProps = "x-has-self-and-ancestor-only-props";
+ /// Whether the model has any variable at all.
+ /// If this is false, the modal MUST be serialized to a scalar value via oneOf or anyOf.
+ private final String kHasAnyVars = "x-has-any-vars";
+ private final String kParentDiscriminator = "x-parent-discriminator";
+
+ Map getInheritanceVariablesLocation(CodegenModel mo) {
+ return mo.vendorExtensions;
+ }
+
+
+ // Workaround weird case in DefaultCodegen where parameter can have isInteger but isNumeric == false.
+ @Override
+ public CodegenParameter fromParameter(Parameter parameter, Set imports) {
+ var result = super.fromParameter(parameter, imports);
+ if (result!=null) {
+ if (result.isInteger || result.isFloat || result.isDouble || result.isLong || result.isShort) {
+ result.isNumeric = true;
+ }
+ }
+ return result;
+ }
+
+ // adapts codegen models and property to dart rules of inheritance
+ private Map adaptToDartInheritance(Map objs) {
+ // get all models
+ Map allModels = new HashMap<>();
+ for (ModelsMap modelsEntries : objs.values()) {
+ for (ModelMap modelsMap : modelsEntries.getModels()) {
+ CodegenModel model = modelsMap.getModel();
+ var hasAnyOfOrOneOf = ((model.anyOf != null && !model.anyOf.isEmpty())
+ || (model.oneOf != null && !model.oneOf.isEmpty()));
+ model.vendorExtensions.put("hasAnyOfOrOneOf", hasAnyOfOrOneOf);
+ // if (model.discriminator != null) {
+ // //if there is a discriminator, make sure it exists in vars.
+ // var discriminatorPropertyResult = model.requiredVars.stream()
+ // .filter(t ->
+ // t.baseName.equals(model.discriminator.getPropertyBaseName())).findFirst();
+
+ // if (discriminatorPropertyResult.isPresent()) {
+ // final CodegenProperty discriminatorProperty =
+ // discriminatorPropertyResult.get();
+ // if (!model.vars.stream().anyMatch(v ->
+ // v.baseName.equals(discriminatorProperty.baseName))) {
+ // model.vars.add(discriminatorProperty);
+ // }
+ // }
+ // }
+ allModels.put(model.getClassname(), model);
+ }
+ }
+
+ // all ancestors
+ Set allAncestorsForAllModelsFlat = new HashSet<>();
+ // maps a model to its ancestors
+ Map> allAncestorsForAllModels = new HashMap<>();
+ for (java.util.Map.Entry cm : allModels.entrySet()) {
+ Set allAncestors = new HashSet<>();
+ // get all ancestors
+ // TODO: optimize this logic ?
+ getAncestors(cm.getValue(), allModels, allAncestors);
+ // just in case, a model can't be its own ancestor
+ allAncestors.remove(cm.getKey());
+
+ allAncestorsForAllModels.put(cm.getKey(), allAncestors);
+ allAncestorsForAllModelsFlat.addAll(allAncestors);
+ }
+
+ Set allPureClasses = new HashSet<>();
+ // set isChild,isParent,isPure
+ for (java.util.Map.Entry cmEntry : allModels.entrySet()) {
+ String key = cmEntry.getKey();
+ CodegenModel cm = cmEntry.getValue();
+ // get all ancestors
+ Set allAncestors = allAncestorsForAllModels.get(key);
+
+ // a class is a parent when it's an ancestor to another class
+ boolean isParent = allAncestorsForAllModelsFlat.contains(key);
+ // a class is a child when it has any ancestor
+ boolean isChild = !allAncestors.isEmpty();
+ // a class is pure when it's not a child, and has no oneOf nor anyOf
+ boolean isPure = !isChild && (cm.oneOf == null || cm.oneOf.isEmpty())
+ && (cm.anyOf == null || cm.anyOf.isEmpty());
+
+ Map varLocation = getInheritanceVariablesLocation(cm);
+ varLocation.put(kIsChild, isChild);
+ varLocation.put(kIsParent, isParent);
+ varLocation.put(kIsPure, isPure);
+ // if (!isParent && (cm.oneOf == null || cm.oneOf.isEmpty())) {
+ // // discriminator has no meaning here
+ // if (cm.discriminator != null) {
+ // varLocation.put(kParentDiscriminator, cm.discriminator);
+ // cm.discriminator = null;
+ // }
+ // }
+ // when pure:
+ // vars = allVars = selfOnlyProperties = kSelfAndAncestorOnlyProps
+ // ancestorOnlyProps = empty
+ if (isPure) {
+ varLocation.put(kHasAnyVars, cm.getAllVars() != null && cm.getAllVars().size() > 0);
+ varLocation.put(kSelfOnlyProps, new ArrayList<>(cm.getVars()));
+ varLocation.put(kHasSelfOnlyProps, !cm.getVars().isEmpty());
+ varLocation.put(kAncestorOnlyProps, cm.parentVars = new ArrayList());
+ varLocation.put(kHasAncestorOnlyProps, false);
+ varLocation.put(kSelfAndAncestorOnlyProps, cm.allVars = new ArrayList<>(cm.getVars()));
+ varLocation.put(kHasSelfAndAncestorOnlyProps, !cm.getVars().isEmpty());
+
+ allPureClasses.add(key);
+ }
+ }
+
+ // handle impure models
+ for (java.util.Map.Entry cmEntry : allModels.entrySet()) {
+ String key = cmEntry.getKey();
+ CodegenModel cm = cmEntry.getValue();
+ if (allPureClasses.contains(key)) {
+ continue;
+ }
+ // get all ancestors
+ Set allAncestors = allAncestorsForAllModels.get(key);
+
+ // get direct parents
+ // Set directParentNames = cm.allOf == null ? new HashSet<>() :
+ // cm.allOf;
+ Set compositeProperties = new HashSet<>();
+
+ Set compositeModelNames = new HashSet();
+ compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.oneOf, new HashSet<>()));
+ compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.anyOf, new HashSet<>()));
+ compositeModelNames.addAll(allAncestors);
+
+ for (String compositeModelName : compositeModelNames) {
+ CodegenModel model = allModels.get(compositeModelName);
+ if (model == null)
+ continue;
+ List allVars = ObjectUtils.firstNonNull(model.getAllVars(), new ArrayList<>());
+ for (CodegenProperty prop : allVars) {
+ compositeProperties.add(prop.getName());
+ }
+ }
+ // dart classes declare selfOnlyProperties as direct members (they exist in
+ // "vars")
+ // for pure models, this will equal vars
+ Map selfOnlyProperties = new HashMap<>();
+
+ // ancestorOnlyProperties are properties defined by all ancestors
+ // NOTE: oneOf,anyOf are NOT considered ancestors
+ // since a child in dart must implement ALL OF the parent (using implements)
+ Map ancestorOnlyProperties = new HashMap<>();
+
+ // combines both selfOnlyProperties and ancestorOnlyProperties
+ // this will be used by the custom serializer as "x-handled-vars" and
+ // "x-has-handled-vars"
+ Map selfAndAncestorOnlyProperties = new HashMap<>();
+
+ // STEP 1: calculating selfOnlyProperties
+ // get all vars of all ancestors and add them to ancestorPropNames
+ // Set _ancestorPropNames = new HashSet<>();
+ for (String ancestorKey : allAncestors) {
+ CodegenModel ancestorCM = allModels.get(ancestorKey);
+ if (ancestorCM != null) {
+ for (CodegenProperty prop : ancestorCM.getVars()) {
+ ancestorOnlyProperties.put(prop.getName(), prop);
+ }
+ }
+ }
+ for (CodegenProperty p : cm.getVars()) {
+ p.isInherited = ancestorOnlyProperties.containsKey(p.getName());
+ if (!p.isInherited && (!compositeProperties.contains(p.getName()) || p.isDiscriminator)) {
+ selfOnlyProperties.put(p.getName(), p);
+ }
+ }
+ selfAndAncestorOnlyProperties.putAll(selfOnlyProperties);
+ selfAndAncestorOnlyProperties.putAll(ancestorOnlyProperties);
+
+ Map varLocation = getInheritanceVariablesLocation(cm);
+ varLocation.put(kHasAnyVars, cm.getAllVars() != null && cm.getAllVars().size() > 0);
+ varLocation.put(kSelfOnlyProps, cm.vars = new ArrayList<>(selfOnlyProperties.values()));
+ varLocation.put(kHasSelfOnlyProps, !selfOnlyProperties.isEmpty());
+ varLocation.put(kAncestorOnlyProps, cm.parentVars = new ArrayList<>(ancestorOnlyProperties.values()));
+ varLocation.put(kHasAncestorOnlyProps, !ancestorOnlyProperties.isEmpty());
+ varLocation.put(kSelfAndAncestorOnlyProps,
+ cm.allVars = new ArrayList<>(selfAndAncestorOnlyProperties.values()));
+ varLocation.put(kHasSelfAndAncestorOnlyProps, !selfAndAncestorOnlyProperties.isEmpty());
+ }
+
+ return objs;
+ }
+
+ /// Gets all ancestors of a given model, and puts it in accumulator
+ private void getAncestors(CodegenModel cm, Map allModels, Set accumulator) {
+
+ // get direct parents
+ Set directParentNames = cm.allOf;
+ if (directParentNames != null && !directParentNames.isEmpty()) {
+ for (String directParentName : directParentNames) {
+ if (accumulator.add(directParentName)) {
+ CodegenModel parent = allModels.get(directParentName);
+ if (parent != null) {
+ getAncestors(parent, allModels, accumulator);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public Map postProcessAllModels(Map objs) {
+ objs = super.postProcessAllModels(objs);
+ objs = super.updateAllModels(objs);
+ objs = adaptToDartInheritance(objs);
+
+ return objs;
+ }
+
+ // private void addSharedInfrastructureFiles() {
+
+ // String sharedInfrastructureFolder = "shared_infrastructure" + File.separator;
+
+ // String libFolder = sharedInfrastructureFolder + "lib" + File.separator;
+ // String srcFolder = libFolder + "src" + File.separator;
+ // String networkingFolder = srcFolder + "networking" + File.separator;
+ // String serializationFolder = srcFolder + "serialization" + File.separator;
+ // supportingFiles.add(new SupportingFile(sharedInfrastructureFolder +
+ // "pubspec.mustache", sharedInfrastructureFolder,
+ // "pubspec.yaml"));
+ // supportingFiles.add(
+ // new SupportingFile(libFolder + "shared_infrastructure.dart", libFolder,
+ // "shared_infrastructure.dart"));
+ // // Networking
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "_exports.mustache", networkingFolder,
+ // "_exports.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "client.mustache", networkingFolder,
+ // "client.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "helpers.mustache", networkingFolder,
+ // "helpers.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "http_packets.mustache",
+ // networkingFolder, "http_packets.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "request.mustache", networkingFolder,
+ // "request.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "request.multipart.mustache",
+ // networkingFolder, "request.multipart.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(networkingFolder + "response.mustache", networkingFolder,
+ // "response.dart"));
+
+ // // Serialization
+ // supportingFiles.add(
+ // new SupportingFile(serializationFolder + "_exports.mustache",
+ // serializationFolder, "_exports.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(serializationFolder + "helpers.mustache",
+ // serializationFolder, "helpers.dart"));
+ // supportingFiles.add(
+ // new SupportingFile(serializationFolder + "undefined_wrapper.mustache",
+ // serializationFolder,
+ // "undefined_wrapper.dart"));
+
+ // }
+
+ @Override
+ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) {
+ var result = super.postProcessOperationsWithModels(objs, allModels);
+ var operations = result.getOperations();
+ for (var operation : operations.getOperation()) {
+ var bodyParam = operation.bodyParam;
+ if (bodyParam == null) {
+ continue;
+ }
+ var resultContentMap = bodyParam.getContent();
+ if (resultContentMap == null) {
+ continue;
+ }
+ var betterConsumes = new ArrayList