Remove deprecations 5.0 (#6060)

* [breaking] Enforce vendor extension naming convention

* [breaking] Rename system properties to global properties

* [docs] Update site with global properties list and usage explanation

* Use proper vendor extension casing in all templates

* Set remaining vendor extensions to convention of lower kebab-cased with x- prefix

* [samples] Regenerate

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java

Before we were adding hasPathParams twice, once with !op.pathParams.isEmpty(), and then again with hasPathParams. This was probably caused by a mistaken merge.

This is causing the difference in samples

Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>

* [Samples] Regenerated!

* Fix -D conversion to additional-properties, missed in bat files

* JERSEY2 option changed

* [samples] Regenerate

* [scala][finch] Fix remaining vendor extensions format to conventino

* [scala] The -D option was replaced with --global-property

* [samples] Regenerate

* Fix -DskipFormModel usage which has been moved to --global-property skipFormModel=true

* [samples] Regenerate

Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>
This commit is contained in:
Jim Schubert
2020-05-31 07:14:31 -04:00
committed by GitHub
parent 40a7e53b19
commit 7e5f720f20
124 changed files with 404 additions and 5185 deletions

View File

@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex -DskipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -38,6 +38,6 @@ find samples/client/petstore/ruby-faraday/spec -type f -not -name petstore_helpe
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -38,6 +38,6 @@ find samples/client/petstore/ruby/spec -type f -not -name petstore_helper.rb -no
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --additional-properties skipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch -DskipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server -DskipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz -DskipFormModel=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz --global-property skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient -Dlibrary=httpclient
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient --additional-properties library=httpclient
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -14,7 +14,7 @@ echo Removing files and folders under %STUB_DIR%
del /F /S /Q %STUB_DIR%
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% -DpackageName=petstore
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstore
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -90,7 +90,8 @@ You can use this as additional dependency of the `openapi-generator-maven-plugin
If you publish your artifact to a distant maven repository, do not forget to add this repository as `pluginRepository` for your project.
## Selective generation
You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output:
You may not want to generate *all* models in your project. Likewise, you may want just one or two apis to be written. If that's the case, you can use system properties or [global properties](./global-properties.md) to control the output.
The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated:
@@ -142,7 +143,13 @@ When using selective generation, _only_ the templates needed for the specific ge
To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2)
```sh
java -DskipFormModel=true
java -DskipFormModel=true <path to jar> generate …
```
or
```sh
java <path to jar> generate --global-property skipFormModel=true
```
This option will be helpful to skip model generation due to the form parameter, which is defined differently in OAS3 as there's no form parameter in OAS3

43
docs/global-properties.md Normal file
View File

@@ -0,0 +1,43 @@
---
id: globals
title: Global Properties
---
## Available Global Properties
| Property | Description | Acceptable value |
| -------- | ------------| ---------------- |
| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none |
| debugModels | Dumps JSON formatted template-bound model information during generation | none |
| debugOperations | Dumps JSON formatted template-bound operation information during generation | none |
| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none |
| verbose | Defines the verbosity | `true` or `false` |
| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` |
| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` |
| supportingFiles | Allows the user to define which supporting files will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of file names |
| models | Allows the user to define which models will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of model names |
| apis | Allows the user to define which apis will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of api names |
| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` |
| withXml | Allows the user to control support of XML generated constructs, where supported | none |
## Note on Global Property declaration
There are _two ways_ to provide selective generation properties or "global properties". First, these can be passed as Java System Properties. Second, these can be passed via the global property tooling option (`--global-property` in CLI and `globalProperty` in Maven and Gradle configurations). This differentiation is new in version 5.0 with the removal of the `-D` CLI option and the renaming of `systemProperties`. If you're upgrading to OpenAPI Generator 5.0+
While the examples seen in [Customization](./customization.md) use the Java System Property syntax, keep in mind that the following are equivalent:
```sh
java -Dmodels {jar} generate {opts}
```
and
```sh
java {jar} generate {opts} --global-property=models
```
Why the two differing ways to provide the same properties? We previously accepted a `-D` tooling option which resembled Java System Property declaration. In older versions of OpenAPI Generator, the option modified the SystemProperties collection directly and was truly a "system property". This option changed during the 4.x release in an effort to make OpenAPI Generator thread-safe and isolate its configuration via thread locals. We no longer mutate System Properties. In the 4.x release and earlier, specifying the tooling `-D` option with system properties intended for other tools like swagger-parser rather than passing them as true Java System Properties would lead to unexpected behavior for the user; if our tool set the system property _after_ invoking certain code, it would seem to the user like Java System Properties weren't working!

View File

@@ -261,14 +261,14 @@ SYNOPSIS
[(-a <authorization> | --auth <authorization>)]
[--api-name-suffix <api name suffix>] [--api-package <api package>]
[--artifact-id <artifact id>] [--artifact-version <artifact version>]
[(-c <configuration file> | --config <configuration file>)]
[-D <system properties>...] [--dry-run]
[(-c <configuration file> | --config <configuration file>)] [--dry-run]
[(-e <templating engine> | --engine <templating engine>)]
[--enable-post-process-file]
[(-g <generator name> | --generator-name <generator name>)]
[--generate-alias-as-model] [--git-host <git host>]
[--git-repo-id <git repo id>] [--git-user-id <git user id>]
[--group-id <group id>] [--http-user-agent <http user agent>]
[--global-property <global properties>...] [--group-id <group id>]
[--http-user-agent <http user agent>]
(-i <spec file> | --input-spec <spec file>)
[--ignore-file-override <ignore file override location>]
[--import-mappings <import mappings>...]
@@ -324,10 +324,6 @@ OPTIONS
different for each language. Run config-help -g {generator name}
command for language-specific config options.
-D <system properties>
sets specified system properties in the format of
name=value,name=value (or multiple options, each with name=value)
--dry-run
Try things out and report on potential changes (without actually
making changes).
@@ -343,11 +339,11 @@ OPTIONS
--generate-alias-as-model
Generate model implementation for aliases to map and array schemas.
An 'alias' is an array, map, or list which is defined inline in a
OpenAPI document and becomes a model in the generated code.
A 'map' schema is an object that can have undeclared properties,
i.e. the 'additionalproperties' attribute is set on that object.
An 'array' schema is a list of sub schemas in a OAS document.
An 'alias' is an array, map, or list which is defined inline in a
OpenAPI document and becomes a model in the generated code. A 'map'
schema is an object that can have undeclared properties, i.e. the
'additionalproperties' attribute is set on that object. An 'array'
schema is a list of sub schemas in a OAS document
--git-host <git host>
Git host, e.g. gitlab.com.
@@ -358,6 +354,11 @@ OPTIONS
--git-user-id <git user id>
Git user ID, e.g. openapitools.
--global-property <global properties>
sets specified global properties (previously called 'system
properties') in the format of name=value,name=value (or multiple
options, each with name=value)
--group-id <group id>
groupId in generated pom.xml

View File

@@ -71,9 +71,8 @@ public class Generate extends OpenApiGeneratorCommand {
+ "Pass in a URL-encoded string of name:header with a comma separating multiple values")
private String auth;
// TODO: Remove -D short option in 5.0
@Option(
name = {"-D", "--global-property"},
name = {"--global-property"},
title = "global properties",
description = "sets specified global properties (previously called 'system properties') in "
+ "the format of name=value,name=value (or multiple options, each with name=value)")

View File

@@ -47,7 +47,7 @@ public class WorkflowSettings {
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = "mustache";
public static final ImmutableMap<String, String> DEFAULT_SYSTEM_PROPERTIES = ImmutableMap.of();
public static final ImmutableMap<String, String> DEFAULT_GLOBAL_PROPERTIES = ImmutableMap.of();
private String inputSpec;
private String outputDir = DEFAULT_OUTPUT_DIR;
@@ -62,7 +62,7 @@ public class WorkflowSettings {
private String templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String ignoreFileOverride;
private ImmutableMap<String, String> systemProperties = DEFAULT_SYSTEM_PROPERTIES;
private ImmutableMap<String, String> globalProperties = DEFAULT_GLOBAL_PROPERTIES;
private WorkflowSettings(Builder builder) {
this.inputSpec = builder.inputSpec;
@@ -78,15 +78,7 @@ public class WorkflowSettings {
this.templateDir = builder.templateDir;
this.templatingEngineName = builder.templatingEngineName;
this.ignoreFileOverride = builder.ignoreFileOverride;
// TODO: rename to globalProperties for 5.0
this.systemProperties = ImmutableMap.copyOf(builder.systemProperties);
if (this.systemProperties.size() > 0) {
// write no more than every 5s. This is temporary until version 5.0 as once(Logger) is not accessible here.
// thread contention may cause this to write more than once, but this is just an attempt to reduce noise
if (System.currentTimeMillis() - lastWarning.getAndUpdate(x -> System.currentTimeMillis()) > 5000) {
LOGGER.warn("systemProperties will be renamed to globalProperties in version 5.0");
}
}
this.globalProperties = ImmutableMap.copyOf(builder.globalProperties);
}
/**
@@ -117,7 +109,7 @@ public class WorkflowSettings {
builder.ignoreFileOverride = copy.getIgnoreFileOverride();
// this, and any other collections, must be mutable in the builder.
builder.systemProperties = new HashMap<>(copy.getSystemProperties());
builder.globalProperties = new HashMap<>(copy.getGlobalProperties());
// force builder "with" methods to invoke side effects
builder.withTemplateDir(copy.getTemplateDir());
@@ -264,8 +256,8 @@ public class WorkflowSettings {
*
* @return the system properties
*/
public Map<String, String> getSystemProperties() {
return systemProperties;
public Map<String, String> getGlobalProperties() {
return globalProperties;
}
/**
@@ -288,7 +280,7 @@ public class WorkflowSettings {
private String ignoreFileOverride;
// NOTE: All collections must be mutable in the builder, and copied to a new immutable collection in .build()
private Map<String, String> systemProperties = new HashMap<>();;
private Map<String, String> globalProperties = new HashMap<>();;
private Builder() {
}
@@ -469,30 +461,30 @@ public class WorkflowSettings {
}
/**
* Sets the {@code systemProperties} and returns a reference to this Builder so that the methods can be chained together.
* Sets the {@code globalProperties} and returns a reference to this Builder so that the methods can be chained together.
*
* @param systemProperties the {@code systemProperties} to set
* @param globalProperties the {@code globalProperties} to set
* @return a reference to this Builder
*/
public Builder withSystemProperties(Map<String, String> systemProperties) {
if (systemProperties != null) {
this.systemProperties = systemProperties;
public Builder withGlobalProperties(Map<String, String> globalProperties) {
if (globalProperties != null) {
this.globalProperties = globalProperties;
}
return this;
}
/**
* Sets the {@code systemProperties} and returns a reference to this Builder so that the methods can be chained together.
* Sets the {@code globalProperties} and returns a reference to this Builder so that the methods can be chained together.
*
* @param key The key of a system (global) property to set
* @param value The value of a system (global) property to set
* @return a reference to this Builder
*/
public Builder withSystemProperty(String key, String value) {
if (this.systemProperties == null) {
this.systemProperties = new HashMap<>();
public Builder withGlobalProperty(String key, String value) {
if (this.globalProperties == null) {
this.globalProperties = new HashMap<>();
}
this.systemProperties.put(key, value);
this.globalProperties.put(key, value);
return this;
}
@@ -526,7 +518,7 @@ public class WorkflowSettings {
", templateDir='" + templateDir + '\'' +
", templatingEngineName='" + templatingEngineName + '\'' +
", ignoreFileOverride='" + ignoreFileOverride + '\'' +
", systemProperties=" + systemProperties +
", globalProperties=" + globalProperties +
'}';
}
@@ -548,7 +540,7 @@ public class WorkflowSettings {
Objects.equals(getTemplateDir(), that.getTemplateDir()) &&
Objects.equals(getTemplatingEngineName(), that.getTemplatingEngineName()) &&
Objects.equals(getIgnoreFileOverride(), that.getIgnoreFileOverride()) &&
Objects.equals(getSystemProperties(), that.getSystemProperties());
Objects.equals(getGlobalProperties(), that.getGlobalProperties());
}
@Override
@@ -567,7 +559,7 @@ public class WorkflowSettings {
getTemplateDir(),
getTemplatingEngineName(),
getIgnoreFileOverride(),
getSystemProperties()
getGlobalProperties()
);
}
}

View File

@@ -50,19 +50,19 @@ public class WorkflowSettingsTest {
}
@Test
public void newBuilderFromCopyShouldMutateSystemProperties(){
public void newBuilderFromCopyShouldMutateGlobalProperties(){
WorkflowSettings original = WorkflowSettings.newBuilder()
.withOutputDir("output")
.withVerbose(true)
.withSkipOverwrite(false)
.withSystemProperty("first", "1st")
.withGlobalProperty("first", "1st")
.build();
WorkflowSettings modified = WorkflowSettings.newBuilder(original)
.withSystemProperty("second", "2nd")
.withGlobalProperty("second", "2nd")
.build();
Map<String, String> properties = modified.getSystemProperties();
Map<String, String> properties = modified.getGlobalProperties();
assertEquals(properties.size(), 2, "System Properties map should allow mutation when invoked via copy constructor");
assertEquals(properties.getOrDefault("first", ""), "1st");
assertEquals(properties.getOrDefault("second", ""), "2nd");

View File

@@ -135,10 +135,10 @@ apply plugin: 'org.openapi.generator'
|None
|Adds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values.
|systemProperties
|globalProperties
|Map(String,String)
|None
|Sets specified system properties.
|Sets specified global properties.
|configFile
|String
@@ -346,12 +346,12 @@ For more control over generation of individual files, configure an ignore file a
[NOTE]
====
When configuring `systemProperties` in order to perform selective generation you can disable generation of some parts by providing `"false"` value:
When configuring `globalProperties` in order to perform selective generation you can disable generation of some parts by providing `"false"` value:
[source,groovy]
----
openApiGenerate {
// other settings omitted
systemProperties = [
globalProperties = [
modelDocs: "false",
apis: "false"
]
@@ -362,7 +362,7 @@ When enabling generation of only specific parts you either have to provide CSV l
----
openApiGenerate {
// other settings omitted
systemProperties = [
globalProperties = [
apis: "",
models: "User,Pet"
]
@@ -609,7 +609,7 @@ task buildKotlinClient(type: org.openapitools.generator.gradle.plugin.tasks.Gene
configOptions = [
dateLibrary: "java8"
]
systemProperties = [
globalProperties = [
modelDocs: "false"
]
}

View File

@@ -42,7 +42,7 @@ openApiGenerate {
configOptions = [
dateLibrary: "java8"
]
systemProperties = [
globalProperties = [
modelDocs: "false"
]
skipValidateSpec = true
@@ -74,7 +74,7 @@ task buildDotnetSdk(type: org.openapitools.generator.gradle.plugin.tasks.Generat
useCompareNetObjects: "true"
]
outputDir = "$buildDir/csharp-netcore".toString()
systemProperties = [
globalProperties = [
models: "",
apis : "",
]

View File

@@ -98,7 +98,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
inputSpec.set(generate.inputSpec)
templateDir.set(generate.templateDir)
auth.set(generate.auth)
systemProperties.set(generate.systemProperties)
globalProperties.set(generate.globalProperties)
configFile.set(generate.configFile)
skipOverwrite.set(generate.skipOverwrite)
packageName.set(generate.packageName)

View File

@@ -65,9 +65,9 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
val auth = project.objects.property<String>()
/**
* Sets specified system properties.
* Sets specified global properties.
*/
val systemProperties = project.objects.mapProperty<String, String>()
val globalProperties = project.objects.mapProperty<String, String>()
/**
* Path to json configuration file.

View File

@@ -97,10 +97,10 @@ open class GenerateTask : DefaultTask() {
val auth = project.objects.property<String>()
/**
* Sets specified system properties.
* Sets specified global properties.
*/
@get:Internal
val systemProperties = project.objects.mapProperty<String, String>()
val globalProperties = project.objects.mapProperty<String, String>()
/**
* Path to json configuration file.
@@ -415,9 +415,9 @@ open class GenerateTask : DefaultTask() {
} else CodegenConfigurator()
try {
if (systemProperties.isPresent) {
systemProperties.get().forEach { (key, value) ->
configurator.addSystemProperty(key, value)
if (globalProperties.isPresent) {
globalProperties.get().forEach { (key, value) ->
configurator.addGlobalProperty(key, value)
}
}
@@ -582,10 +582,9 @@ open class GenerateTask : DefaultTask() {
}
}
if (systemProperties.isPresent) {
// TODO: rename to globalProperties in 5.0
systemProperties.get().forEach { entry ->
configurator.addSystemProperty(entry.key, entry.value)
if (globalProperties.isPresent) {
globalProperties.get().forEach { entry ->
configurator.addGlobalProperty(entry.key, entry.value)
}
}

View File

@@ -85,14 +85,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "verbose", defaultValue = "false")
private boolean verbose;
// TODO: 5.0 Remove `language` option.
/**
* Client language to generate.
*/
@Parameter(name = "language")
private String language;
/**
* The name of the generator to use.
*/
@@ -538,20 +530,8 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
if (isNotEmpty(generatorName)) {
configurator.setGeneratorName(generatorName);
// check if generatorName & language are set together, inform user this needs to be updated to prevent future issues.
if (isNotEmpty(language)) {
LOGGER.warn("The 'language' option is deprecated and was replaced by 'generatorName'. Both can not be set together");
throw new MojoExecutionException(
"Illegal configuration: 'language' and 'generatorName' can not be set both, remove 'language' from your configuration");
}
} else if (isNotEmpty(language)) {
LOGGER.warn(
"The 'language' option is deprecated and may reference language names only in the next major release (4.0). Please use 'generatorName' instead.");
configurator.setGeneratorName(language);
} else {
LOGGER.error("A generator name (generatorName) is required.");
throw new MojoExecutionException("The generator requires 'generatorName'. Refer to documentation for a list of options.");
@@ -724,7 +704,7 @@ public class CodeGenMojo extends AbstractMojo {
originalEnvironmentVariables.put(key, GlobalSettings.getProperty(key));
String value = environmentVariables.get(key);
if (value != null) {
configurator.addSystemProperty(key, value);
configurator.addGlobalProperty(key, value);
}
}
}

View File

@@ -61,7 +61,7 @@ public class CodegenConfigurator {
private String generatorName;
private String inputSpec;
private String templatingEngineName;
private Map<String, String> systemProperties = new HashMap<>();
private Map<String, String> globalProperties = new HashMap<>();
private Map<String, String> instantiationTypes = new HashMap<>();
private Map<String, String> typeMappings = new HashMap<>();
private Map<String, Object> additionalProperties = new HashMap<>();
@@ -91,8 +91,8 @@ public class CodegenConfigurator {
configurator.generatorName = generatorSettings.getGeneratorName();
configurator.inputSpec = workflowSettings.getInputSpec();
configurator.templatingEngineName = workflowSettings.getTemplatingEngineName();
if (workflowSettings.getSystemProperties() != null) {
configurator.systemProperties.putAll(workflowSettings.getSystemProperties());
if (workflowSettings.getGlobalProperties() != null) {
configurator.globalProperties.putAll(workflowSettings.getGlobalProperties());
}
if(generatorSettings.getInstantiationTypes() != null) {
configurator.instantiationTypes.putAll(generatorSettings.getInstantiationTypes());
@@ -183,10 +183,9 @@ public class CodegenConfigurator {
return this;
}
// TODO: rename this and other references to "global property" rather than "system property"
public CodegenConfigurator addSystemProperty(String key, String value) {
this.systemProperties.put(key, value);
workflowSettingsBuilder.withSystemProperty(key, value);
public CodegenConfigurator addGlobalProperty(String key, String value) {
this.globalProperties.put(key, value);
workflowSettingsBuilder.withGlobalProperty(key, value);
return this;
}
@@ -385,9 +384,9 @@ public class CodegenConfigurator {
return this;
}
public CodegenConfigurator setSystemProperties(Map<String, String> systemProperties) {
this.systemProperties = systemProperties;
workflowSettingsBuilder.withSystemProperties(systemProperties);
public CodegenConfigurator setGlobalProperties(Map<String, String> globalProperties) {
this.globalProperties = globalProperties;
workflowSettingsBuilder.withGlobalProperties(globalProperties);
return this;
}
@@ -450,7 +449,7 @@ public class CodegenConfigurator {
GlobalSettings.setProperty("verbose", "false");
}
for (Map.Entry<String, String> entry : workflowSettings.getSystemProperties().entrySet()) {
for (Map.Entry<String, String> entry : workflowSettings.getGlobalProperties().entrySet()) {
GlobalSettings.setProperty(entry.getKey(), entry.getValue());
}

View File

@@ -42,39 +42,6 @@ import java.util.*;
*/
public final class CodegenConfiguratorUtils {
/**
* Applies "system" properties to the configurator as global properties.
*
* @deprecated
* This method is deprecated due to confusion around the tool's use of system properties. We called these system properties
* in the past and accepted them via CLI option -D. This lead to confusion between true Java System Properties and generator-specific
* "system level properties". They've since been renamed as "Global Properties". Please use {@link CodegenConfiguratorUtils#applyGlobalPropertiesKvpList(List, CodegenConfigurator)}.
*
* @param systemProperties List of properties to be globally available throughout the generator execution.
* @param configurator The {@link CodegenConfigurator} instance to configure.
*/
@Deprecated
public static void applySystemPropertiesKvpList(List<String> systemProperties, CodegenConfigurator configurator) {
// TODO: Remove in 5.0
applyGlobalPropertiesKvpList(systemProperties, configurator);
}
/**
* Applies a key-value pair of strings as "system" properties to the configurator as global properties.
*
* @deprecated
* This method is deprecated due to confusing between Java Sytsem Properties and generator-specific "system-level properties".
* They've since been renamed as "Global Properties". Please use {@link CodegenConfiguratorUtils#applyGlobalPropertiesKvp(String, CodegenConfigurator)}.
*
* @param systemProperties List of properties to be globally available throughout the generator execution.
* @param configurator The {@link CodegenConfigurator} instance to configure.
*/
@Deprecated
public static void applySystemPropertiesKvp(String systemProperties, CodegenConfigurator configurator) {
// TODO: Remove in 5.0
applyGlobalPropertiesKvp(systemProperties, configurator);
}
public static void applyGlobalPropertiesKvpList(List<String> globalProperties, CodegenConfigurator configurator) {
for(String propString : globalProperties) {
applyGlobalPropertiesKvp(propString, configurator);
@@ -84,7 +51,7 @@ public final class CodegenConfiguratorUtils {
public static void applyGlobalPropertiesKvp(String globalProperties, CodegenConfigurator configurator) {
final Map<String, String> map = createMapFromKeyValuePairs(globalProperties);
for (Map.Entry<String, String> entry : map.entrySet()) {
configurator.addSystemProperty(entry.getKey(), entry.getValue());
configurator.addGlobalProperty(entry.getKey(), entry.getValue());
}
}

View File

@@ -456,13 +456,6 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
}
}
// TODO: 5.0: Remove this block and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
cm.vendorExtensions.put("hasPropertyMappings", !propertyMappings.isEmpty()); // TODO: 5.0 Remove
cm.vendorExtensions.put("hasDefaultValues", hasDefaultValues); // TODO: 5.0 Remove
cm.vendorExtensions.put("propertyMappings", propertyMappings); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-has-property-mappings", !propertyMappings.isEmpty());
cm.vendorExtensions.put("x-has-default-values", hasDefaultValues);
cm.vendorExtensions.put("x-property-mappings", propertyMappings);

View File

@@ -590,14 +590,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
* @param models list of all models
*/
protected void updateValueTypeProperty(Map<String, Object> models) {
// TODO: 5.0: Remove the camelCased vendorExtension within the below loop and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Map.Entry<String, Object> entry : models.entrySet()) {
String openAPIName = entry.getKey();
CodegenModel model = ModelUtils.getModelByName(openAPIName, models);
if (model != null) {
for (CodegenProperty var : model.vars) {
var.vendorExtensions.put("isValueType", isValueType(var)); // TODO: 5.0 Remove
var.vendorExtensions.put("x-is-value-type", isValueType(var));
}
}

View File

@@ -235,19 +235,14 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
char firstChar = parameter.paramName.charAt(0);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (Character.isUpperCase(firstChar)) {
// First char is already uppercase, just use paramName.
parameter.vendorExtensions.put("x-exportParamName", parameter.paramName); // TODO: 5.0 Remove
parameter.vendorExtensions.put("x-export-param-name", parameter.paramName);
}
// It's a lowercase first char, let's convert it to uppercase
StringBuilder sb = new StringBuilder(parameter.paramName);
sb.setCharAt(0, Character.toUpperCase(firstChar));
parameter.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove
parameter.vendorExtensions.put("x-export-param-name", sb.toString());
}

View File

@@ -457,9 +457,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@SuppressWarnings("unchecked")
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenOperation operation : operations) {
// http method verb conversion (e.g. PUT => Put)
operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
@@ -525,12 +522,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// We need to specially map Time type to the optionals package
if ("time.Time".equals(param.dataType)) {
param.vendorExtensions.put("x-optionalDataType", "Time"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-optional-data-type", "Time");
} else {
// Map optional type to dataType
String optionalType = param.dataType.substring(0, 1).toUpperCase(Locale.ROOT) + param.dataType.substring(1);
param.vendorExtensions.put("x-optionalDataType", optionalType); // TODO: 5.0 Remove
param.vendorExtensions.put("x-optional-data-type", optionalType);
}
}
@@ -539,13 +534,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
char nameFirstChar = param.paramName.charAt(0);
if (Character.isUpperCase(nameFirstChar)) {
// First char is already uppercase, just use paramName.
param.vendorExtensions.put("x-exportParamName", param.paramName); // TODO: 5.0 Remove
param.vendorExtensions.put("x-export-param-name", param.paramName);
} else {
// It's a lowercase first char, let's convert it to uppercase
StringBuilder sb = new StringBuilder(param.paramName);
sb.setCharAt(0, Character.toUpperCase(nameFirstChar));
param.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove
param.vendorExtensions.put("x-export-param-name", sb.toString());
}
}
@@ -579,21 +572,15 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
}
private void setExportParameterName(List<CodegenParameter> codegenParameters) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenParameter param : codegenParameters) {
char nameFirstChar = param.paramName.charAt(0);
if (Character.isUpperCase(nameFirstChar)) {
// First char is already uppercase, just use paramName.
param.vendorExtensions.put("x-exportParamName", param.paramName); // TODO: 5.0 Remove
param.vendorExtensions.put("x-export-param-name", param.paramName);
} else {
// It's a lowercase first char, let's convert it to uppercase
StringBuilder sb = new StringBuilder(param.paramName);
sb.setCharAt(0, Character.toUpperCase(nameFirstChar));
param.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove
param.vendorExtensions.put("x-export-param-name", sb.toString());
}
}

View File

@@ -1034,12 +1034,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
if (serializeBigDecimalAsString) {
if (property.baseType.equals("BigDecimal")) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
// we serialize BigDecimal as `string` to avoid precision loss
property.vendorExtensions.put("extraAnnotation", "@JsonSerialize(using = ToStringSerializer.class)"); // TODO: 5.0 Remove
property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = ToStringSerializer.class)");
// this requires some more imports to be added for this model...

View File

@@ -675,14 +675,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenOperation op : operationList) {
// for API test method name
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId)); // TODO: 5.0 Remove
op.vendorExtensions.put("x-test-operation-id", camelize(op.operationId));
}
return objs;

View File

@@ -96,9 +96,6 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenOperation op : operationList) {
String path = op.path;
@@ -111,7 +108,6 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
splitPath.add(item);
op.path += item + "/";
}
op.vendorExtensions.put("x-codegen-userInfoPath", userInfoPath); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-user-info-path", userInfoPath);
boolean foundInNewList = false;
for (CodegenOperation op1 : newOpList) {
@@ -124,7 +120,6 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
}
op.operationIdCamelCase = op1.operationIdCamelCase;
currentOtherMethodList.add(op);
op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList); // TODO: 5.0 Remove
op1.vendorExtensions.put("x-codegen-other-methods", currentOtherMethodList);
}
}

View File

@@ -47,7 +47,6 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
private static final String PROJECT_LICENSE_URL = "projectLicenseUrl";
private static final String BASE_NAMESPACE = "baseNamespace";
static final String X_BASE_SPEC = "x-baseSpec"; // TODO: 5.0 Remove
static final String VENDOR_EXTENSION_X_BASE_SPEC = "x-base-spec";
static final String X_MODELS = "x-models";
@@ -202,16 +201,10 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
@Override
public CodegenModel fromModel(String name, Schema mod) {
CodegenModel model = super.fromModel(name, mod);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
// If a var is a base spec we won't need to import it
for (CodegenProperty var : model.vars) {
var.vendorExtensions.put(X_BASE_SPEC, baseSpecs.contains(var.complexType)); // TODO: 5.0 Remove
var.vendorExtensions.put(VENDOR_EXTENSION_X_BASE_SPEC, baseSpecs.contains(var.complexType));
if (var.items != null) {
var.items.vendorExtensions.put(X_BASE_SPEC, baseSpecs.contains(var.items.complexType)); // TODO: 5.0 Remove
var.items.vendorExtensions.put(VENDOR_EXTENSION_X_BASE_SPEC, baseSpecs.contains(var.items.complexType));
}
}

View File

@@ -253,10 +253,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
String classname = (String) operations.get("classname");
operations.put("classnameSnakeUpperCase", underscore(classname).toUpperCase(Locale.ROOT));
operations.put("classnameSnakeLowerCase", underscore(classname).toLowerCase(Locale.ROOT));
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
boolean consumeJson = false;
@@ -267,7 +263,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
}
boolean isStringOrDate = op.bodyParam.isString || op.bodyParam.isDate;
op.bodyParam.vendorExtensions.put("x-codegen-pistache-isStringOrDate", isStringOrDate); // TODO: 5.0 Remove
op.bodyParam.vendorExtensions.put("x-codegen-pistache-is-string-or-date", isStringOrDate);
}
if (op.consumes != null) {
@@ -302,9 +297,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
if (op.vendorExtensions == null) {
op.vendorExtensions = new HashMap<>();
}
op.vendorExtensions.put("x-codegen-pistache-consumesJson", consumeJson); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-pistache-consumes-json", consumeJson);
op.vendorExtensions.put("x-codegen-pistache-isParsingSupported", isParsingSupported); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-pistache-is-parsing-supported", isParsingSupported);
// Check if any one of the operations needs a model, then at API file level, at least one model has to be included.

View File

@@ -287,9 +287,6 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenOperation op : operationList) {
String path = op.path;
@@ -311,7 +308,6 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
}
op.path += item + "/";
}
op.vendorExtensions.put("x-codegen-resourceName", resourceNameCamelCase); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-resource-name", resourceNameCamelCase);
boolean foundInNewList = false;
@@ -325,7 +321,6 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
}
op.operationIdCamelCase = op1.operationIdCamelCase;
currentOtherMethodList.add(op);
op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList); // TODO: 5.0 Remove
op1.vendorExtensions.put("x-codegen-other-methods", currentOtherMethodList);
}
}

View File

@@ -270,9 +270,6 @@ public class DartDioClientCodegen extends DartClientCodegen {
List<Object> models = (List<Object>) objs.get("models");
ProcessUtils.addIndexToProperties(models, 1);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
Set<String> modelImports = new HashSet<>();
@@ -289,7 +286,6 @@ public class DartDioClientCodegen extends DartClientCodegen {
cm.imports = modelImports;
boolean hasVars = cm.vars.size() > 0;
cm.vendorExtensions.put("hasVars", hasVars); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-has-vars", hasVars);
}
return objs;
@@ -356,13 +352,6 @@ public class DartDioClientCodegen extends DartClientCodegen {
}
}
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
op.vendorExtensions.put("isJson", isJson); // TODO: 5.0 Remove
op.vendorExtensions.put("isForm", isForm); // TODO: 5.0 Remove
op.vendorExtensions.put("isMultipart", isMultipart); // TODO: 5.0 Remove
op.vendorExtensions.put("x-is-json", isJson);
op.vendorExtensions.put("x-is-form", isForm);
op.vendorExtensions.put("x-is-multipart", isMultipart);

View File

@@ -225,9 +225,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
List<Object> models = (List<Object>) objs.get("models");
ProcessUtils.addIndexToProperties(models, 1);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
Set<String> modelImports = new HashSet<>();
@@ -249,7 +246,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
cm.imports = modelImports;
boolean hasVars = cm.vars.size() > 0;
cm.vendorExtensions.put("hasVars", hasVars); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-has-vars", hasVars);
}
return objs;
@@ -259,9 +255,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
@@ -305,11 +298,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
}
op.vendorExtensions.put("isForm", isForm); // TODO: 5.0 Remove
op.vendorExtensions.put("isJson", isJson); // TODO: 5.0 Remove
op.vendorExtensions.put("isProto", isProto); // TODO: 5.0 Remove
op.vendorExtensions.put("isMultipart", isMultipart); // TODO: 5.0 Remove
op.vendorExtensions.put("x-is-form", isForm);
op.vendorExtensions.put("x-is-json", isJson);
op.vendorExtensions.put("x-is-proto", isProto);

View File

@@ -38,7 +38,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -88,24 +87,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
static final String MIME_ANY = "MimeAny";
// vendor extensions. These must follow our convention of x- prefixed and lower-kebab cased.
static final String X_COLLECTION_FORMAT = "x-collectionFormat"; // TODO: 5.0 Remove
static final String X_HADDOCK_PATH = "x-haddockPath"; // TODO: 5.0 Remove
static final String X_HAS_BODY_OR_FORM_PARAM = "x-hasBodyOrFormParam"; // TODO: 5.0 Remove
static final String X_HAS_MIME_FORM_URL_ENCODED = "x-hasMimeFormUrlEncoded"; // TODO: 5.0 Remove
static final String X_HAS_NEW_TAG = "x-hasNewTag"; // TODO: 5.0 Remove
static final String X_HAS_OPTIONAL_PARAMS = "x-hasOptionalParams"; // TODO: 5.0 Remove
static final String X_HAS_UNKNOWN_RETURN = "x-hasUnknownReturn"; // TODO: 5.0 Remove
static final String X_INLINE_CONTENT_TYPE = "x-inlineContentType"; // TODO: 5.0 Remove
static final String X_INLINE_ACCEPT = "x-inlineAccept"; // TODO: 5.0 Remove
static final String X_IS_BODY_OR_FORM_PARAM = "x-isBodyOrFormParam"; // TODO: 5.0 Remove
static final String X_IS_MAYBE_VALUE = "x-isMaybeValue"; // TODO: 5.0 Remove
static final String X_DATA_TYPE = "x-dataType"; // TODO: 5.0 Remove
static final String X_MIME_TYPES = "x-mimeTypes"; // TODO: 5.0 Remove
static final String X_OPERATION_TYPE = "x-operationType"; // TODO: 5.0 Remove
static final String X_PARAM_NAME_TYPE = "x-paramNameType"; // TODO: 5.0 Remove
static final String X_RETURN_TYPE = "x-returnType"; // TODO: 5.0 Remove
static final String X_UNKNOWN_MIME_TYPES = "x-unknownMimeTypes"; // TODO: 5.0 Remove
static final String VENDOR_EXTENSION_X_UNKNOWN_MIME_TYPES = "x-unknown-mime-types";
static final String VENDOR_EXTENSION_X_COLLECTION_FORMAT = "x-collection-format";
static final String VENDOR_EXTENSION_X_HADDOCK_PATH = "x-haddock-path";
static final String VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM = "x-has-body-or-form-param";
@@ -687,10 +669,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation op, Map<String, List<CodegenOperation>> operations) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
List<CodegenOperation> opList = operations.get(tag);
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
@@ -727,33 +705,25 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
op.vendorExtensions = new LinkedHashMap();
String operationType = toTypeName("Op", op.operationId);
op.vendorExtensions.put(X_OPERATION_TYPE, operationType); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_OPERATION_TYPE, operationType);
typeNames.add(operationType);
String xHaddockPath = String.format(Locale.ROOT, "%s %s", op.httpMethod, op.path.replace("/", "\\/"));
op.vendorExtensions.put(X_HADDOCK_PATH, xHaddockPath); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_HADDOCK_PATH, xHaddockPath);
op.vendorExtensions.put(X_HAS_BODY_OR_FORM_PARAM, op.getHasBodyParam() || op.getHasFormParams()); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM, op.getHasBodyParam() || op.getHasFormParams());
for (CodegenParameter param : op.allParams) {
param.vendorExtensions = new LinkedHashMap(); // prevent aliasing/sharing
param.vendorExtensions.put(X_OPERATION_TYPE, operationType); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_OPERATION_TYPE, operationType);
param.vendorExtensions.put(X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam);
if (!StringUtils.isBlank(param.collectionFormat)) {
param.vendorExtensions.put(X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
} else if (!param.isBodyParam && (param.isListContainer || param.dataType.startsWith("["))) { // param.isListContainer is sometimes false for list types
// defaulting due to https://github.com/wing328/openapi-generator/issues/72
param.collectionFormat = "csv";
param.vendorExtensions.put(X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat));
}
if (!param.required) {
op.vendorExtensions.put(X_HAS_OPTIONAL_PARAMS, true); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_OPTIONAL_PARAMS, true);
}
@@ -764,7 +734,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
String dataType = genEnums && param.isEnum ? param.datatypeWithEnum : param.dataType;
String paramNameType = toDedupedModelName(toTypeName("Param", param.paramName), dataType, !(param.isEnum || param.allowableValues != null));
param.vendorExtensions.put(X_PARAM_NAME_TYPE, paramNameType); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_PARAM_NAME_TYPE, paramNameType);
HashMap<String, Object> props = new HashMap<>();
@@ -809,16 +778,16 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
return o1.get(MEDIA_TYPE).compareTo(o2.get(MEDIA_TYPE));
}
});
additionalProperties.put(X_UNKNOWN_MIME_TYPES, unknownMimeTypes);
additionalProperties.put(VENDOR_EXTENSION_X_UNKNOWN_MIME_TYPES, unknownMimeTypes);
ArrayList<Map<String, Object>> params = new ArrayList<>(uniqueParamNameTypes.values());
Collections.sort(params, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
return
((String) o1.get(X_PARAM_NAME_TYPE))
((String) o1.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE))
.compareTo(
(String) o2.get(X_PARAM_NAME_TYPE));
(String) o2.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE));
}
});
additionalProperties.put(X_ALL_UNIQUE_PARAMS, params);
@@ -827,14 +796,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> ret = super.postProcessOperationsWithModels(objs, allModels);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
HashMap<String, Object> pathOps = (HashMap<String, Object>) ret.get("operations");
ArrayList<CodegenOperation> ops = (ArrayList<CodegenOperation>) pathOps.get("operation");
if (ops.size() > 0) {
ops.get(0).vendorExtensions.put(X_HAS_NEW_TAG, true); // TODO: 5.0 Remove
ops.get(0).vendorExtensions.put(VENDOR_EXTENSION_X_HAS_NEW_TAG, true);
}
@@ -846,7 +810,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (modelMimeTypes.containsKey(m.classname)) {
Set<String> mimeTypes = modelMimeTypes.get(m.classname);
m.vendorExtensions.put(X_MIME_TYPES, mimeTypes); // TODO: 5.0 Remove
m.vendorExtensions.put(VENDOR_EXTENSION_X_MIME_TYPES, mimeTypes);
if ((boolean) additionalProperties.get(PROP_GENERATE_FORM_URLENCODED_INSTANCES) && mimeTypes.contains("MimeFormUrlEncoded")) {
@@ -857,7 +820,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
}
}
if (hasMimeFormUrlEncoded) {
m.vendorExtensions.put(X_HAS_MIME_FORM_URL_ENCODED, true); // TODO: 5.0 Remove
m.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_MIME_FORM_URL_ENCODED, true);
}
}
@@ -919,14 +881,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (returnType == null || returnType.equals("null")) {
if (op.hasProduces) {
returnType = "res";
op.vendorExtensions.put(X_HAS_UNKNOWN_RETURN, true); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_UNKNOWN_RETURN, true);
} else {
returnType = "NoContent";
// TODO: 5.0 Remove vendor extension usage which is not lower-kebab cased.
if (!op.vendorExtensions.containsKey(X_INLINE_ACCEPT)) {
SetNoContent(op, X_INLINE_ACCEPT);
}
if (!op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_ACCEPT)) {
SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT);
}
@@ -935,13 +892,11 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (returnType.contains(" ")) {
returnType = "(" + returnType + ")";
}
op.vendorExtensions.put(X_RETURN_TYPE, returnType); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_RETURN_TYPE, returnType);
}
private void processProducesConsumes(CodegenOperation op) {
if (!(Boolean) op.vendorExtensions.get(X_HAS_BODY_OR_FORM_PARAM)) {
SetNoContent(op, X_INLINE_CONTENT_TYPE); // TODO: 5.0 Remove
if (!(Boolean) op.vendorExtensions.get(VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM)) {
SetNoContent(op, VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE);
}
if (op.hasConsumes) {
@@ -979,20 +934,15 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
}
private void processInlineConsumesContentType(CodegenOperation op, Map<String, String> m) {
if (op.vendorExtensions.containsKey(X_INLINE_CONTENT_TYPE)) return;
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE)) return;
if ((boolean) additionalProperties.get(PROP_INLINE_MIME_TYPES)
&& op.consumes.size() == 1
&& !MIME_ANY.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE))
&& !MIME_NO_CONTENT.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE))) {
op.vendorExtensions.put(X_INLINE_CONTENT_TYPE, m); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE, m);
for (CodegenParameter param : op.allParams) {
if (param.isBodyParam && param.required) {
param.vendorExtensions.put(X_INLINE_CONTENT_TYPE, m); // TODO: 5.0 Remove
param.vendorExtensions.put(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE, m);
}
}
@@ -1005,10 +955,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
&& !MIME_ANY.equals(op.produces.get(0).get(X_MEDIA_DATA_TYPE))
&& !MIME_NO_CONTENT.equals(op.produces.get(0).get(X_MEDIA_DATA_TYPE))) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
op.vendorExtensions.put(X_INLINE_ACCEPT, m); // TODO: 5.0 Remove
op.vendorExtensions.put(VENDOR_EXTENSION_X_INLINE_ACCEPT, m);
}
}
@@ -1041,7 +987,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public Boolean isDuplicate(String paramNameType, String dataType) {
Map<String, Object> lastParam = this.uniqueParamNameTypes.get(paramNameType);
if (lastParam != null) {
String comparisonKey = lastParam.containsKey(VENDOR_EXTENSION_X_ENUM) ? X_ENUM_VALUES : X_DATA_TYPE;
String comparisonKey = lastParam.containsKey(VENDOR_EXTENSION_X_ENUM) ? X_ENUM_VALUES : VENDOR_EXTENSION_X_DATA_TYPE;
String lastParamDataType = (String) lastParam.get(comparisonKey);
if (lastParamDataType != null && lastParamDataType.equals(dataType)) {
return true;
@@ -1053,7 +999,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
private Pair<Boolean, String> isDuplicateEnumValues(String enumValues) {
for (Map<String, Object> vs : uniqueParamNameTypes.values()) {
if (enumValues.equals(vs.get(X_ENUM_VALUES))) {
return Pair.of(true, (String) vs.get(X_PARAM_NAME_TYPE));
return Pair.of(true, (String) vs.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE));
}
}
return Pair.of(false, null);
@@ -1062,8 +1008,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
private void addToUniques(String xGroup, String paramNameType, String dataType, Map<String, Object> props) {
HashMap<String, Object> m = new HashMap<>();
m.put(X_PARAM_NAME_TYPE, paramNameType);
m.put(X_DATA_TYPE, dataType);
m.put(VENDOR_EXTENSION_X_PARAM_NAME_TYPE, paramNameType);
m.put(VENDOR_EXTENSION_X_DATA_TYPE, dataType);
m.put(xGroup, true);
m.putAll(props);
uniqueParamNameTypes.put(paramNameType, m);
@@ -1323,9 +1269,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
@@ -1335,10 +1278,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
if (dataType == null && cm.isArrayModel) { // isAlias + arrayModelType missing "datatype"
dataType = "[" + cm.arrayModelType + "]";
}
cm.vendorExtensions.put(X_DATA_TYPE, dataType); // TODO: 5.0 Remove
cm.vendorExtensions.put(VENDOR_EXTENSION_X_DATA_TYPE, dataType);
if (dataType.equals("Maybe A.Value")) {
cm.vendorExtensions.put(X_IS_MAYBE_VALUE, true); // TODO: 5.0 Remove
cm.vendorExtensions.put(VENDOR_EXTENSION_X_IS_MAYBE_VALUE, true);
}
}
@@ -1346,10 +1287,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
String datatype = genEnums && !StringUtils.isBlank(var.datatypeWithEnum)
? var.datatypeWithEnum
: var.dataType;
var.vendorExtensions.put(X_DATA_TYPE, datatype); // TODO: 5.0 Remove
var.vendorExtensions.put(VENDOR_EXTENSION_X_DATA_TYPE, datatype);
if (!var.required && datatype.equals("A.Value") || var.required && datatype.equals("Maybe A.Value")) {
var.vendorExtensions.put(X_IS_MAYBE_VALUE, true); // TODO: 5.0 Remove
var.vendorExtensions.put(VENDOR_EXTENSION_X_IS_MAYBE_VALUE, true);
}
}

View File

@@ -507,9 +507,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, List<Server> servers) {
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, servers);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
List<String> path = pathToServantRoute(op.path, op.pathParams);
List<String> type = pathToClientType(op.path, op.pathParams);
@@ -562,7 +559,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// store form parameter name in the vendor extensions
for (CodegenParameter param : op.formParams) {
param.vendorExtensions.put("x-formParamName", camelize(param.baseName)); // TODO: 5.0 Remove
param.vendorExtensions.put("x-form-param-name", camelize(param.baseName));
}
@@ -577,14 +573,10 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
path.add("Verb '" + op.httpMethod.toUpperCase(Locale.ROOT) + " 200 '[JSON] " + returnType);
type.add("m " + returnType);
op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path)); // TODO: 5.0 Remove
op.vendorExtensions.put("x-route-type", joinStrings(" :> ", path));
op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type)); // TODO: 5.0 Remove
op.vendorExtensions.put("x-client-type", joinStrings(" -> ", type));
op.vendorExtensions.put("x-formName", "Form" + camelize(op.operationId)); // TODO: 5.0 Remove
op.vendorExtensions.put("x-form-name", "Form" + camelize(op.operationId));
for (CodegenParameter param : op.formParams) {
param.vendorExtensions.put("x-formPrefix", camelize(op.operationId, true)); // TODO: 5.0 Remove
param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, true));
}
return op;
@@ -642,9 +634,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
public CodegenModel fromModel(String name, Schema mod) {
CodegenModel model = super.fromModel(name, mod);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
setGenerateToSchema(model);
// Clean up the class name to remove invalid characters
@@ -663,7 +652,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String dataOrNewtype = "data";
if (!"object".equals(model.dataType) && typeMapping.containsKey(model.dataType)) {
String newtype = typeMapping.get(model.dataType);
model.vendorExtensions.put("x-customNewtype", newtype); // TODO: 5.0 Remove
// note; newtype is a single lowercase word in Haskell (not separated by hyphen)
model.vendorExtensions.put("x-custom-newtype", newtype);
}

View File

@@ -750,14 +750,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
return objs;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
List<Object> models = (List<Object>) objs.get("models");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) {
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
for (Object _mo : models) {
@@ -768,7 +766,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
boolean isOptionalNullable = Boolean.FALSE.equals(var.required) && Boolean.TRUE.equals(var.isNullable);
// only add JsonNullable and related imports to optional and nullable values
addImports |= isOptionalNullable;
var.getVendorExtensions().put("isJacksonOptionalNullable", isOptionalNullable); // TODO: 5.0 Remove
var.getVendorExtensions().put("x-is-jackson-optional-nullable", isOptionalNullable);
}
if (addImports) {
@@ -791,9 +788,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
cm.getVendorExtensions().putIfAbsent("implements", new ArrayList<String>()); // TODO: 5.0 Remove
cm.getVendorExtensions().putIfAbsent("x-implements", cm.getVendorExtensions().get("implements"));
//List<String> impl = (List<String>) cm.getVendorExtensions().get("x-implements");
cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList<String>());
if (JERSEY2.equals(getLibrary())) {
cm.getVendorExtensions().put("x-implements", new ArrayList<String>());

View File

@@ -291,9 +291,6 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
@@ -320,11 +317,9 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
if (operation.returnType != null) {
if (operation.returnType.equals("Boolean")) {
operation.vendorExtensions.put("missingReturnInfoIfNeeded", "true"); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-missing-return-info-if-needed", "true");
}
if (operation.returnType.equals("BigDecimal")) {
operation.vendorExtensions.put("missingReturnInfoIfNeeded", "1.0"); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-missing-return-info-if-needed", "1.0");
}
if (operation.returnType.startsWith("List")) {

View File

@@ -814,9 +814,6 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
@Override
public CodegenModel fromModel(String name, Schema model) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
@@ -829,22 +826,17 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
ArraySchema am = (ArraySchema) model;
if (codegenModel != null && am.getItems() != null) {
String itemType = getSchemaType(am.getItems());
codegenModel.vendorExtensions.put("x-isArray", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-array", true);
codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-item-type", itemType);
}
} else if (ModelUtils.isMapSchema(model)) {
if (codegenModel != null && getAdditionalProperties(model) != null) {
String itemType = getSchemaType(getAdditionalProperties(model));
codegenModel.vendorExtensions.put("x-isMap", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-map", true);
codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-item-type", itemType);
} else {
String type = model.getType();
if (codegenModel != null && isPrimitiveType(type)) {
codegenModel.vendorExtensions.put("x-isPrimitive", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-primitive", true);
}
}
@@ -918,9 +910,6 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
// vendor-extension: x-codegen-argList.
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
@@ -944,9 +933,7 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
}
String joinedArgList = StringUtils.join(argList, ", ");
operation.vendorExtensions.put("x-codegen-argList", joinedArgList); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-codegen-arg-list", joinedArgList);
operation.vendorExtensions.put("x-codegen-hasOptionalParams", hasOptionalParams); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-codegen-has-optional-params", hasOptionalParams);
// Store JSDoc type specification into vendor-extension: x-jsdoc-type.
@@ -972,9 +959,6 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
objs = super.postProcessModelsEnum(objs);
List<Object> models = (List<Object>) objs.get("models");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
@@ -1025,10 +1009,8 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
for (CodegenProperty var : cm.vars) {
Optional.ofNullable(lastRequired).ifPresent(_lastRequired -> {
if (var == _lastRequired) {
var.vendorExtensions.put("x-codegen-hasMoreRequired", false); // TODO: 5.0 Remove
var.vendorExtensions.put("x-codegen-has-more-required", false);
} else if (var.required) {
var.vendorExtensions.put("x-codegen-hasMoreRequired", true); // TODO: 5.0 Remove
var.vendorExtensions.put("x-codegen-has-more-required", true);
}
});

View File

@@ -862,9 +862,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public CodegenModel fromModel(String name, Schema model) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
@@ -877,22 +874,17 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
ArraySchema am = (ArraySchema) model;
if (codegenModel != null && am.getItems() != null) {
String itemType = getSchemaType(am.getItems());
codegenModel.vendorExtensions.put("x-isArray", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-array", true);
codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-item-type", itemType);
}
} else if (ModelUtils.isMapSchema(model)) {
if (codegenModel != null && getAdditionalProperties(model) != null) {
String itemType = getSchemaType(getAdditionalProperties(model));
codegenModel.vendorExtensions.put("x-isMap", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-map", true);
codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-item-type", itemType);
} else {
String type = model.getType();
if (codegenModel != null && isPrimitiveType(type)) {
codegenModel.vendorExtensions.put("x-isPrimitive", true); // TODO: 5.0 Remove
codegenModel.vendorExtensions.put("x-is-primitive", true);
}
}
@@ -992,9 +984,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// vendor-extension: x-codegen-argList.
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
@@ -1021,9 +1010,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
argList.add("callback");
}
String joinedArgList = StringUtils.join(argList, ", ");
operation.vendorExtensions.put("x-codegen-argList", joinedArgList); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-codegen-arg-list", joinedArgList);
operation.vendorExtensions.put("x-codegen-hasOptionalParams", hasOptionalParams); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-codegen-has-optional-params", hasOptionalParams);
// Store JSDoc type specification into vendor-extension: x-jsdoc-type.
@@ -1049,9 +1036,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
objs = super.postProcessModelsEnum(objs);
List<Object> models = (List<Object>) objs.get("models");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
@@ -1102,10 +1086,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
for (CodegenProperty var : cm.vars) {
Optional.ofNullable(lastRequired).ifPresent(_lastRequired -> {
if (var == _lastRequired) {
var.vendorExtensions.put("x-codegen-hasMoreRequired", false); // TODO: 5.0 Remove
var.vendorExtensions.put("x-codegen-has-more-required", false);
} else if (var.required) {
var.vendorExtensions.put("x-codegen-hasMoreRequired", true); // TODO: 5.0 Remove
var.vendorExtensions.put("x-codegen-has-more-required", true);
}
});

View File

@@ -29,10 +29,10 @@ import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@SuppressWarnings("unchecked")
public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(MysqlSchemaCodegen.class);
public static final String CODEGEN_VENDOR_EXTENSION_KEY = "x-mysqlSchema"; // TODO: 5.0 Remove
public static final String VENDOR_EXTENSION_MYSQL_SCHEMA = "x-mysql-schema";
public static final String DEFAULT_DATABASE_NAME = "defaultDatabaseName";
public static final String JSON_DATA_TYPE_ENABLED = "jsonDataTypeEnabled";
@@ -272,12 +272,11 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
modelDescription = (modelDescription == null || modelDescription.isEmpty()) ? commentExtra : modelDescription + ". " + commentExtra;
}
if (modelVendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (modelVendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + modelName + "' model, autogeneration skipped");
continue;
} else {
modelVendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema);
modelVendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("tableDefinition", tableDefinition);
tableDefinition.put("tblName", tableName);
tableDefinition.put("tblComment", modelDescription);
@@ -336,15 +335,15 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String description = property.getDescription();
String minimum = property.getMinimum();
String maximum = property.getMaximum();
Boolean exclusiveMinimum = property.getExclusiveMinimum();
Boolean exclusiveMaximum = property.getIExclusiveMaximum();
boolean exclusiveMinimum = property.getExclusiveMinimum();
boolean exclusiveMaximum = property.getIExclusiveMaximum();
String defaultValue = property.getDefaultValue();
Boolean required = property.getRequired();
Boolean unsigned = false;
boolean unsigned = false;
Boolean isUuid = property.isUuid;
Boolean isEnum = property.isEnum;
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -356,7 +355,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -364,7 +362,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
if (Boolean.TRUE.equals(isEnum)) {
Map<String, Object> allowableValues = property.getAllowableValues();
List<Object> enumValues = (List<Object>) allowableValues.get("values");
for (Integer i = 0; i < enumValues.size(); i++) {
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
break;
@@ -380,8 +378,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
} else {
Long min = (minimum != null) ? Long.parseLong(minimum) : null;
Long max = (maximum != null) ? Long.parseLong(maximum) : null;
if (exclusiveMinimum == true && min != null) min += 1;
if (exclusiveMaximum == true && max != null) max -= 1;
if (exclusiveMinimum && min != null) min += 1;
if (exclusiveMaximum && max != null) max -= 1;
if (min != null && min >= 0) {
unsigned = true;
}
@@ -425,14 +423,14 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String description = property.getDescription();
String minimum = property.getMinimum();
String maximum = property.getMaximum();
Boolean exclusiveMinimum = property.getExclusiveMinimum();
Boolean exclusiveMaximum = property.getIExclusiveMaximum();
boolean exclusiveMinimum = property.getExclusiveMinimum();
boolean exclusiveMaximum = property.getIExclusiveMaximum();
String defaultValue = property.getDefaultValue();
Boolean required = property.getRequired();
Boolean unsigned = false;
boolean unsigned = false;
Boolean isEnum = property.isEnum;
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -444,7 +442,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -452,7 +449,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
if (Boolean.TRUE.equals(isEnum)) {
Map<String, Object> allowableValues = property.getAllowableValues();
List<Object> enumValues = (List<Object>) allowableValues.get("values");
for (Integer i = 0; i < enumValues.size(); i++) {
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
break;
@@ -465,8 +462,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
} else {
Float min = (minimum != null) ? Float.valueOf(minimum) : null;
Float max = (maximum != null) ? Float.valueOf(maximum) : null;
if (exclusiveMinimum == true && min != null) min += 1;
if (exclusiveMaximum == true && max != null) max -= 1;
if (exclusiveMinimum && min != null) min += 1;
if (exclusiveMaximum && max != null) max -= 1;
if (min != null && min >= 0) {
unsigned = true;
}
@@ -511,7 +508,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String defaultValue = property.getDefaultValue();
Boolean required = property.getRequired();
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -523,7 +520,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -570,7 +566,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
Boolean required = property.getRequired();
Boolean isEnum = property.isEnum;
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -582,7 +578,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -592,7 +587,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
List<Object> enumValues = (List<Object>) allowableValues.get("values");
columnDefinition.put("colDataType", "ENUM");
columnDefinition.put("colDataTypeArguments", columnDataTypeArguments);
for (Integer i = 0; i < enumValues.size(); i++) {
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
break;
@@ -645,7 +640,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String description = property.getDescription();
String defaultValue = property.getDefaultValue();
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -657,7 +652,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -697,7 +691,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String description = property.getDescription();
String defaultValue = property.getDefaultValue();
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -709,7 +703,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -752,7 +745,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
String description = property.getDescription();
String defaultValue = property.getDefaultValue();
if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) {
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
return;
@@ -764,7 +757,6 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra;
}
vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove
vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("columnDefinition", columnDefinition);
columnDefinition.put("colName", colName);
@@ -903,10 +895,10 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
public String getMysqlMatchedIntegerDataType(Long minimum, Long maximum, Boolean unsigned) {
// we can choose fit mysql data type
// ref: https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
Long min = (minimum != null) ? minimum : -2147483648L;
Long max = (maximum != null) ? maximum : 2147483647L;
Long actualMin = Math.min(min, max); // sometimes min and max values can be mixed up
Long actualMax = Math.max(min, max); // sometimes only minimum specified and it can be pretty high
long min = (minimum != null) ? minimum : -2147483648L;
long max = (maximum != null) ? maximum : 2147483647L;
long actualMin = Math.min(min, max); // sometimes min and max values can be mixed up
long actualMax = Math.max(min, max); // sometimes only minimum specified and it can be pretty high
if (minimum != null && maximum != null && minimum > maximum) {
LOGGER.warn("Codegen property 'minimum' cannot be greater than 'maximum'");
}
@@ -949,8 +941,8 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
public String getMysqlMatchedStringDataType(Integer minLength, Integer maxLength) {
// we can choose fit mysql data type
// ref: https://dev.mysql.com/doc/refman/8.0/en/string-type-overview.html
Integer min = (minLength != null && minLength >= 0) ? minLength : 0;
Integer max = (maxLength != null && maxLength >= 0) ? maxLength : 65535;
int min = (minLength != null && minLength >= 0) ? minLength : 0;
int max = (maxLength != null && maxLength >= 0) ? maxLength : 65535;
Integer actualMin = Math.min(min, max); // sometimes minLength and maxLength values can be mixed up
Integer actualMax = Math.max(min, max); // sometimes only minLength specified and it can be pretty high
if (minLength != null && maxLength != null && minLength > maxLength) {
@@ -1140,7 +1132,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
*/
public void setDefaultDatabaseName(String databaseName) {
String escapedName = toDatabaseName(databaseName);
if (escapedName.equals(databaseName) == false) {
if (!escapedName.equals(databaseName)) {
LOGGER.error("Invalid database name. '" + databaseName + "' cannot be used as MySQL identifier. Escaped value '" + escapedName + "' will be used instead.");
}
this.defaultDatabaseName = escapedName;

View File

@@ -45,7 +45,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";
static final String X_MODEL_MODULE = "x-modelModule";
static final String X_MODEL_MODULE = "x-model-module";
public static final String CO_HTTP = "cohttp";
@@ -715,9 +715,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
@SuppressWarnings("unchecked")
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenOperation operation : operations) {
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
//if (CO_HTTP.equals(getLibrary())) {
@@ -728,7 +725,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
}
if ("Yojson.Safe.t".equals(operation.returnBaseType)) {
operation.vendorExtensions.put("x-returnFreeFormObject", true); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-return-free-form-object", true);
}
}

View File

@@ -654,15 +654,11 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
if (!operation.allParams.isEmpty()) {
String firstParamName = operation.allParams.get(0).paramName;
operation.vendorExtensions.put("firstParamAltName", camelize(firstParamName)); // TODO: 5.0 Remove
operation.vendorExtensions.put("x-first-param-alt-name", camelize(firstParamName));
}
}
@@ -673,11 +669,6 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty schema) {
super.postProcessModelProperty(model, schema);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
schema.vendorExtensions.put("x-uppercaseName", camelize(schema.name)); // TODO: 5.0 Remove
schema.vendorExtensions.put("x-uppercase-name", camelize(schema.name));
}

View File

@@ -390,9 +390,6 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
operations.put("controllerName", toControllerName((String) operations.get("pathPrefix")));
operations.put("symfonyService", toSymfonyService((String) operations.get("pathPrefix")));
@@ -408,20 +405,16 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// to the templating engine
String typeHint = getTypeHint(param.dataType);
if (!typeHint.isEmpty()) {
param.vendorExtensions.put("x-parameterType", typeHint); // TODO: 5.0 Remove
param.vendorExtensions.put("x-parameter-type", typeHint);
}
if (param.isContainer) {
param.vendorExtensions.put("x-parameterType", getTypeHint(param.dataType + "[]")); // TODO: 5.0 Remove
param.vendorExtensions.put("x-parameter-type", getTypeHint(param.dataType + "[]"));
}
// Create a variable to display the correct data type in comments for interfaces
param.vendorExtensions.put("x-commentType", param.dataType); // TODO: 5.0 Remove
param.vendorExtensions.put("x-comment-type", param.dataType);
if (param.isContainer) {
param.vendorExtensions.put("x-commentType", param.dataType + "[]"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-comment-type", param.dataType + "[]");
}
@@ -436,14 +429,11 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// Create a variable to display the correct return type in comments for interfaces
if (op.returnType != null) {
op.vendorExtensions.put("x-commentType", op.returnType); // TODO: 5.0 Remove
op.vendorExtensions.put("x-comment-type", op.returnType);
if (op.returnContainer != null && op.returnContainer.equals("array")) {
op.vendorExtensions.put("x-commentType", op.returnType + "[]"); // TODO: 5.0 Remove
op.vendorExtensions.put("x-comment-type", op.returnType + "[]");
}
} else {
op.vendorExtensions.put("x-commentType", "void"); // TODO: 5.0 Remove
op.vendorExtensions.put("x-comment-type", "void");
}
@@ -466,9 +456,6 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
ArrayList<Object> modelsArray = (ArrayList<Object>) objs.get("models");
Map<String, Object> models = (Map<String, Object>) modelsArray.get(0);
CodegenModel model = (CodegenModel) models.get("model");
@@ -480,20 +467,16 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// to the templating engine
String typeHint = getTypeHint(var.dataType);
if (!typeHint.isEmpty()) {
var.vendorExtensions.put("x-parameterType", typeHint); // TODO: 5.0 Remove
var.vendorExtensions.put("x-parameter-type", typeHint);
}
if (var.isContainer) {
var.vendorExtensions.put("x-parameterType", getTypeHint(var.dataType + "[]")); // TODO: 5.0 Remove
var.vendorExtensions.put("x-parameter-type", getTypeHint(var.dataType + "[]"));
}
// Create a variable to display the correct data type in comments for models
var.vendorExtensions.put("x-commentType", var.dataType); // TODO: 5.0 Remove
var.vendorExtensions.put("x-comment-type", var.dataType);
if (var.isContainer) {
var.vendorExtensions.put("x-commentType", var.dataType + "[]"); // TODO: 5.0 Remove
var.vendorExtensions.put("x-comment-type", var.dataType + "[]");
}
}

View File

@@ -36,6 +36,7 @@ import java.util.*;
public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PhpZendExpressivePathHandlerServerCodegen.class);
// TODO: Rename to x- prefixed vendor extensions, per specification.
public static final String VEN_FROM_QUERY = "internal.ze-ph.fromQuery";
public static final String VEN_COLLECTION_FORMAT = "internal.ze-ph.collectionFormat";
public static final String VEN_QUERY_DATA_TYPE = "internal.ze-ph.queryDataType";

View File

@@ -198,9 +198,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
// Index all CodegenModels by model name.
Map<String, CodegenModel> allModels = new HashMap<>();
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Map.Entry<String, Object> entry : objs.entrySet()) {
String modelName = toModelName(entry.getKey());
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
@@ -229,9 +226,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
}
// TODO: figure out how to properly have the original property type that didn't go through toVarName
String vendorExtensionTagName = cm.discriminator.getPropertyName().replace("_", "");
cm.vendorExtensions.put("tagName", vendorExtensionTagName); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-tag-name", vendorExtensionTagName);
cm.vendorExtensions.put("mappedModels", discriminatorVars); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-mapped-models", discriminatorVars);
}
}

View File

@@ -609,9 +609,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
Map<String, Schema> definitions = ModelUtils.getSchemas(this.openAPI);
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
String pathFormatString = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
@@ -705,7 +702,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
hasPathParams = true;
}
op.vendorExtensions.put("callbackParams", params);
op.vendorExtensions.put("x-callback-params", params);
}
// Save off the regular expression and path details in the relevant
@@ -735,28 +732,20 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
String underscoredOperationId = underscore(op.operationId);
op.vendorExtensions.put("operation_id", underscoredOperationId); // TODO: 5.0 Remove
op.vendorExtensions.put("x-operation-id", underscoredOperationId);
op.vendorExtensions.put("uppercase_operation_id", underscoredOperationId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove
op.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId.toUpperCase(Locale.ROOT));
String vendorExtensionPath = op.path.replace("{", ":").replace("}", "");
op.vendorExtensions.put("path", vendorExtensionPath); // TODO: 5.0 Remove
op.vendorExtensions.put("x-path",vendorExtensionPath);
op.vendorExtensions.put("PATH_ID", pathId); // TODO: 5.0 Remove
op.vendorExtensions.put("x-path-id", pathId);
op.vendorExtensions.put("hasPathParams", !op.pathParams.isEmpty()); // TODO: 5.0 Remove
op.vendorExtensions.put("x-has-path-params", !op.pathParams.isEmpty());
op.vendorExtensions.put("hasPathParams", hasPathParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-has-path-params", hasPathParams);
op.vendorExtensions.put("x-path-format-string", formatPath);
String vendorExtensionHttpMethod = op.httpMethod.toUpperCase(Locale.ROOT);
op.vendorExtensions.put("HttpMethod", vendorExtensionHttpMethod); // TODO: 5.0 Remove
op.vendorExtensions.put("x-http-method", vendorExtensionHttpMethod);
// TODO: 5.0 Fix formatting
if (!op.vendorExtensions.containsKey("x-mustUseResponse")) {
if (!op.vendorExtensions.containsKey("x-must-use-response")) {
// If there's more than one response, than by default the user must explicitly handle them
op.vendorExtensions.put("x-mustUseResponse", op.responses.size() > 1);
op.vendorExtensions.put("x-must-use-response", op.responses.size() > 1);
}
for (CodegenParameter param : op.allParams) {
@@ -800,7 +789,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
processParam(param, op);
// Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property.
param.vendorExtensions.put("typeName", toModelName(param.baseName)); // TODO: 5.0 Remove
param.vendorExtensions.put("x-type-name", toModelName(param.baseName));
}
@@ -822,9 +810,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// Create a unique responseID for this response.
String responseId;
if (rsp.vendorExtensions.containsKey("x-responseId")) {
if (rsp.vendorExtensions.containsKey("x-response-id")) {
// If it's been specified directly, use that.
responseId = (String) rsp.vendorExtensions.get("x-responseId");
responseId = (String) rsp.vendorExtensions.get("x-response-id");
} else if ((words.length != 0) && (words[0].trim().length() != 0)) {
// If there's a description, build it from the description.
responseId = camelize(words[0].replace(" ", "_"));
@@ -850,15 +838,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
responseIds.add(responseId);
String underscoredResponseId = underscore(responseId).toUpperCase(Locale.ROOT);
rsp.vendorExtensions.put("x-responseId", responseId); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-response-id", responseId);
rsp.vendorExtensions.put("x-uppercaseResponseId", underscoredResponseId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-uppercase-response-id", underscoredResponseId.toUpperCase(Locale.ROOT));
rsp.vendorExtensions.put("uppercase_operation_id", underscoredOperationId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId.toUpperCase(Locale.ROOT));
if (rsp.dataType != null) {
String uppercaseDataType = (rsp.dataType.replace("models::", "")).toUpperCase(Locale.ROOT);
rsp.vendorExtensions.put("uppercase_data_type", uppercaseDataType); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-uppercase-data-type", uppercaseDataType);
// Get the mimetype which is produced by this response. Note
@@ -908,13 +892,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
outputMime = firstProduces;
}
rsp.vendorExtensions.put("mimeType", outputMime); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-mime-type", outputMime);
// Write out the type of data we actually expect this response
// to make.
if (producesXml) {
rsp.vendorExtensions.put("producesXml", true); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-produces-xml", true);
} else if (producesPlainText) {
// Plain text means that there is not structured data in
@@ -926,14 +908,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// base64 encoding should be done. They both look like
// 'producesBytes'.
if (rsp.dataType.equals(bytesType)) {
rsp.vendorExtensions.put("producesBytes", true); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-produces-bytes", true);
} else {
rsp.vendorExtensions.put("producesPlainText", true); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-produces-plain-text", true);
}
} else {
rsp.vendorExtensions.put("producesJson", true); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-produces-json", true);
// If the data type is just "object", then ensure that the
// Rust data type is "serde_json::Value". This allows us
@@ -950,7 +929,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
if ((model != null)) {
XML xml = model.getXml();
if ((xml != null) && (xml.getNamespace() != null)) {
rsp.vendorExtensions.put("has_namespace", "true"); // TODO: 5.0 Remove
rsp.vendorExtensions.put("x-has-namespace", "true");
}
}
@@ -996,9 +974,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
boolean consumesPlainText = false;
boolean consumesXml = false;
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (op.consumes != null) {
for (Map<String, String> consume : op.consumes) {
if (consume.get("mediaType") != null) {
@@ -1012,12 +987,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
} else if (isMimetypeWwwFormUrlEncoded(mediaType)) {
additionalProperties.put("usesUrlEncodedForm", true);
} else if (isMimetypeMultipartFormData(mediaType)) {
op.vendorExtensions.put("consumesMultipart", true); // TODO Remove: 5.0 Remove
op.vendorExtensions.put("x-consumes-multipart", true);
additionalProperties.put("apiUsesMultipartFormData", true);
additionalProperties.put("apiUsesMultipart", true);
} else if (isMimetypeMultipartRelated(mediaType)) {
op.vendorExtensions.put("consumesMultipartRelated", true);
op.vendorExtensions.put("x-consumes-multipart-related", true);
additionalProperties.put("apiUsesMultipartRelated", true);
additionalProperties.put("apiUsesMultipart", true);
}
@@ -1028,16 +1002,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
String underscoredOperationId = underscore(op.operationId).toUpperCase(Locale.ROOT);
if (op.bodyParam != null) {
// Default to consuming json
op.bodyParam.vendorExtensions.put("uppercase_operation_id", underscoredOperationId); // TODO: 5.0 Remove
op.bodyParam.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId);
if (consumesXml) {
op.bodyParam.vendorExtensions.put("consumesXml", true); // TODO: 5.0 Remove
op.bodyParam.vendorExtensions.put("x-consumes-xml", true);
} else if (consumesPlainText) {
op.bodyParam.vendorExtensions.put("consumesPlainText", true); // TODO: 5.0 Remove
op.bodyParam.vendorExtensions.put("x-consumes-plain-text", true);
} else {
op.bodyParam.vendorExtensions.put("consumesJson", true); // TODO: 5.0 Remove
op.bodyParam.vendorExtensions.put("x-consumes-json", true);
}
}
@@ -1045,18 +1015,14 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenParameter param : op.bodyParams) {
processParam(param, op);
param.vendorExtensions.put("uppercase_operation_id", underscoredOperationId); // TODO: 5.0 Remove
param.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId);
// Default to producing json if nothing else is specified
if (consumesXml) {
param.vendorExtensions.put("consumesXml", true); // TODO: 5.0 Remove
param.vendorExtensions.put("x-consumes-xml", true);
} else if (consumesPlainText) {
param.vendorExtensions.put("consumesPlainText", true); // TODO: 5.0 Remove
param.vendorExtensions.put("x-consumes-plain-text", true);
} else {
param.vendorExtensions.put("consumesJson", true); // TODO: 5.0 Remove
param.vendorExtensions.put("x-consumes-json", true);
}
}
@@ -1082,7 +1048,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
for (CodegenSecurity s : op.authMethods) {
if (s.isApiKey && s.isKeyInHeader) {
s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName)); // TODO: 5.0 Remove
s.vendorExtensions.put("x-api-key-name", toModelName(s.keyParamName));
headerAuthMethods = true;
}
@@ -1093,7 +1058,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
if (headerAuthMethods) {
op.vendorExtensions.put("hasHeaderAuthMethods", "true"); // TODO: 5.0 Remove
op.vendorExtensions.put("x-has-header-auth-methods", "true");
}
}
@@ -1220,13 +1184,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public CodegenModel fromModel(String name, Schema model) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel mdl = super.fromModel(name, model);
mdl.vendorExtensions.put("upperCaseName", name.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove
mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT));
if (!StringUtils.isEmpty(model.get$ref())) {
Schema schema = allDefinitions.get(ModelUtils.getSimpleRef(model.get$ref()));
@@ -1258,7 +1217,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// If this model's items require wrapping in xml, squirrel away the
// xml name so we can insert it into the relevant model fields.
if (xmlName != null) {
mdl.vendorExtensions.put("itemXmlName", xmlName); // TODO: 5.0 Remove
mdl.vendorExtensions.put("x-item-xml-name", xmlName);
modelXmlNames.put("models::" + mdl.classname, xmlName);
}
@@ -1287,9 +1245,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
Map<String, Object> newObjs = super.postProcessAllModels(objs);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
//Index all CodegenModels by model name.
HashMap<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
for (Entry<String, Object> entry : objs.entrySet()) {
@@ -1317,7 +1272,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
String xmlName = modelXmlNames.get(prop.dataType);
if (xmlName != null) {
prop.vendorExtensions.put("itemXmlName", xmlName); // TODO: 5.0 Remove
prop.vendorExtensions.put("x-item-xml-name", xmlName);
}
@@ -1564,9 +1518,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
@@ -1608,7 +1559,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
}
cm.vendorExtensions.put("isString", "String".equals(cm.dataType)); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-is-string", "String".equals(cm.dataType));
}
return super.postProcessModelsEnum(objs);
@@ -1618,38 +1568,30 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
String example = null;
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
// If a parameter uses UUIDs, we need to import the UUID package.
if (uuidType.equals(param.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
if (Boolean.TRUE.equals(param.isFreeFormObject)) {
param.vendorExtensions.put("formatString", "{:?}");
param.vendorExtensions.put("x-format-string", "{:?}");
example = null;
} else if (param.isString) {
param.vendorExtensions.put("formatString", "\\\"{}\\\""); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "\\\"{}\\\""); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "\\\"{}\\\"");
example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()";
} else if (param.isPrimitiveType) {
if ((param.isByteArray) || (param.isBinary)) {
// Binary primitive types don't implement `Display`.
param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{:?}");
example = "swagger::ByteArray(Vec::from(\"" + ((param.example != null) ? param.example : "") + "\"))";
} else {
param.vendorExtensions.put("formatString", "{}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{}");
example = (param.example != null) ? param.example : "";
}
} else if (param.isListContainer) {
param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{:?}");
example = (param.example != null) ? param.example : "&Vec::new()";
} else {
param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{:?}");
if (param.example != null) {
example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")";
@@ -1658,30 +1600,22 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
if (param.required) {
if (example != null) {
param.vendorExtensions.put("example", example); // TODO: 5.0 Remove
param.vendorExtensions.put("x-example", example);
} else if (param.isListContainer) {
// Use the empty list if we don't have an example
param.vendorExtensions.put("example", "&Vec::new()"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-example", "&Vec::new()");
} else {
// If we don't have an example that we can provide, we need to disable the client example, as it won't build.
param.vendorExtensions.put("example", "???"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-example", "???");
op.vendorExtensions.put("noClientExample", Boolean.TRUE); // TODO: 5.0 Remove
op.vendorExtensions.put("x-no-client-example", Boolean.TRUE);
}
} else if ((param.dataFormat != null) && ((param.dataFormat.equals("date-time")) || (param.dataFormat.equals("date")))) {
param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{:?}");
param.vendorExtensions.put("example", "None"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-example", "None");
} else {
// Not required, so override the format string and example
param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove
param.vendorExtensions.put("x-format-string", "{:?}");
String exampleString = (example != null) ? "Some(" + example + ")" : "None";
param.vendorExtensions.put("example", exampleString); // TODO: 5.0 Remove
param.vendorExtensions.put("x-example", exampleString);
}
}

View File

@@ -240,9 +240,9 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
// Converts GET /foo/bar => get("foo" :: "bar")
generateScalaPath(op);
// Generates e.g. uuid :: header("boo") :: params("baa") under key "x-codegen-pathParams"
// Generates e.g. (id: UUID, headerBoo: String, paramBaa: String) under key "x-codegen-typedInputParams"
// Generates e.g. (id, headerBoo, paramBaa) under key "x-codegen-inputParams"
// Generates e.g. uuid :: header("boo") :: params("baa") under key "x-codegen-path-params"
// Generates e.g. (id: UUID, headerBoo: String, paramBaa: String) under key "x-codegen-typed-input-params"
// Generates e.g. (id, headerBoo, paramBaa) under key "x-codegen-input-params"
generateInputParameters(op);
//Generate Auth parameters using security: definition
@@ -346,9 +346,6 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
String authInputParams = "";
String typedAuthInputParams = "";
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
//Append apikey security to path params and create input parameters for functions
if (op.authMethods != null) {
@@ -365,10 +362,6 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
}
}
op.vendorExtensions.put("x-codegen-authParams", authParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-authInputParams", authInputParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-typedAuthInputParams", typedAuthInputParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-auth-params", authParams);
op.vendorExtensions.put("x-codegen-auth-input-params", authInputParams);
op.vendorExtensions.put("x-codegen-typed-auth-input-params", typedAuthInputParams);
@@ -414,18 +407,13 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
private void concatParameters(CodegenOperation op) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
String path = colConcat(colConcat(op.vendorExtensions.get("x-codegen-path").toString(), op.vendorExtensions.get("x-codegen-pathParams").toString()), op.vendorExtensions.get("x-codegen-authParams").toString());
String parameters = csvConcat(op.vendorExtensions.get("x-codegen-inputParams").toString(), op.vendorExtensions.get("x-codegen-authInputParams").toString());
String typedParameters = csvConcat(op.vendorExtensions.get("x-codegen-typedInputParams").toString(), op.vendorExtensions.get("x-codegen-typedAuthInputParams").toString());
String path = colConcat(colConcat(op.vendorExtensions.get("x-codegen-path").toString(), op.vendorExtensions.get("x-codegen-path-params").toString()), op.vendorExtensions.get("x-codegen-auth-params").toString());
String parameters = csvConcat(op.vendorExtensions.get("x-codegen-input-params").toString(), op.vendorExtensions.get("x-codegen-auth-input-params").toString());
String typedParameters = csvConcat(op.vendorExtensions.get("x-codegen-typed-input-params").toString(), op.vendorExtensions.get("x-codegen-typed-auth-input-params").toString());
// The input parameters for functions
op.vendorExtensions.put("x-codegen-paths", path);
op.vendorExtensions.put("x-codegen-params", parameters);
op.vendorExtensions.put("x-codegen-typedParams", typedParameters); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-typed-params", typedParameters);
}
@@ -433,9 +421,6 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
private void generateInputParameters(CodegenOperation op) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
String inputParams = "";
String typedInputParams = "";
String pathParams = "";
@@ -482,13 +467,10 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
}
// All body, path, query and header parameters
op.vendorExtensions.put("x-codegen-pathParams", pathParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-path-params", pathParams);
// The input parameters for functions
op.vendorExtensions.put("x-codegen-inputParams", inputParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-input-params", inputParams);
op.vendorExtensions.put("x-codegen-typedInputParams", typedInputParams); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-typed-input-params", typedInputParams);
}

View File

@@ -258,9 +258,6 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
objs = super.postProcessAllModels(objs);
Map<String, CodegenModel> modelsByClassName = new HashMap<>();
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (Object _outer : objs.values()) {
Map<String, Object> outer = (Map<String, Object>) _outer;
List<Map<String, Object>> models = (List<Map<String, Object>>) outer.get("models");
@@ -271,7 +268,6 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
cm.classVarName = camelize(cm.classVarName, true);
modelsByClassName.put(cm.classname, cm);
boolean hasFiles = cm.vars.stream().anyMatch(var -> var.isFile);
cm.vendorExtensions.put("hasFiles", hasFiles); // TODO: 5.0 Remove
cm.vendorExtensions.put("x-has-files", hasFiles);
}
}
@@ -289,9 +285,6 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
objs = super.postProcessSupportingFileData(objs);
generateJSONSpecFile(objs);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
// Prettify routes file
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
@@ -304,11 +297,9 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
.reduce(0, Integer::max);
ops.forEach(op -> {
String paddedPath = rightPad(op.path, maxPathLength - op.httpMethod.length());
op.vendorExtensions.put("paddedPath", paddedPath); // TODO: 5.0 Remove
op.vendorExtensions.put("x-padded-path", paddedPath);
});
ops.forEach(op -> {
op.vendorExtensions.put("hasPathParams", op.getHasPathParams()); // TODO: 5.0 Remove
op.vendorExtensions.put("x-has-path-params", op.getHasPathParams());
});

View File

@@ -202,10 +202,6 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (op.returnType != null) {
op.returnType = normalizeType(op.returnType);
}
@@ -214,7 +210,6 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
op.path = sanitizePath(op.path);
String methodUpperCase = httpMethod.toUpperCase(Locale.ROOT);
op.vendorExtensions.put("x-codegen-httpMethodUpperCase", methodUpperCase); // TODO: 5.0 Remove
op.vendorExtensions.put("x-codegen-http-method-upper-case", methodUpperCase);
return op;
@@ -248,9 +243,6 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
public List<CodegenParameter> postProcessParameterEnum(List<CodegenParameter> parameterList) {
String enumFormatted = "";
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
for (CodegenParameter parameter : parameterList) {
if (parameter.isEnum) {
for (int i = 0; i < parameter._enum.size(); i++) {
@@ -262,7 +254,6 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
Markdown markInstance = new Markdown();
if (!enumFormatted.isEmpty()) {
String formattedExtension = markInstance.toHtml(enumFormatted);
parameter.vendorExtensions.put("x-eumFormatted", formattedExtension); // TODO: 5.0 Remove
parameter.vendorExtensions.put("x-eum-formatted", formattedExtension);
}
}

View File

@@ -249,11 +249,7 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
private void setParamNameAlternative(CodegenParameter param, String paramName, String paramNameAlternative) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
if (param.paramName.equals(paramName)) {
param.vendorExtensions.put("paramNameAlternative", paramNameAlternative); // TODO: 5.0 Remove
param.vendorExtensions.put("x-param-name-alternative", paramNameAlternative);
}
}

View File

@@ -103,18 +103,13 @@ public class OneOfImplementorAdditionalData {
* @param implImports imports of the implementing model
* @param addInterfaceImports whether or not to add the interface model as import (will vary by language)
*/
@SuppressWarnings("unchecked")
public void addToImplementor(CodegenConfig cc, CodegenModel implcm, List<Map<String, String>> implImports, boolean addInterfaceImports) {
// TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming.
once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix.");
implcm.getVendorExtensions().putIfAbsent("implements", new ArrayList<String>()); // TODO: 5.0 Remove
implcm.getVendorExtensions().putIfAbsent("x-implements", implcm.getVendorExtensions().get("implements"));
implcm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList<String>());
// Add implemented interfaces
for (String intf : additionalInterfaces) {
List<String> impl = (List<String>) implcm.getVendorExtensions().get("implements");
List<String> impl = (List<String>) implcm.getVendorExtensions().get("x-implements");
impl.add(intf);
if (addInterfaceImports) {
// Add imports for interfaces

View File

@@ -86,18 +86,18 @@ private class {{classname}}Test {
System.assertEquals({{classVarName}}3.hashCode(), {{classVarName}}4.hashCode());
}
{{#vendorExtensions}}
{{#hasPropertyMappings}}
{{#x-has-property-mappings}}
@isTest
private static void maintainRenamedProperties() {
{{classname}} {{classVarName}} = new {{classname}}();
Map<String, String> propertyMappings = {{classVarName}}.getPropertyMappings();
{{#propertyMappings}}
System.assertEquals('{{internalName}}', propertyMappings.get('{{externalName}}'));
{{/propertyMappings}}
Map<String, String> x-property-mappings = {{classVarName}}.getx-property-mappings();
{{#x-property-mappings}}
System.assertEquals('{{internalName}}', x-property-mappings.get('{{externalName}}'));
{{/x-property-mappings}}
}
{{/hasPropertyMappings}}
{{#hasDefaultValues}}
{{/x-has-property-mappings}}
{{#x-has-default-values}}
@isTest
private static void defaultValuesPopulated() {
@@ -113,7 +113,7 @@ private class {{classname}}Test {
{{/defaultValue}}
{{/vars}}
}
{{/hasDefaultValues}}
{{/x-has-default-values}}
{{/vendorExtensions}}
{{/isEnum}}
}

View File

@@ -34,19 +34,19 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{#interfac
{{/vars}}
{{#vendorExtensions}}
{{#hasPropertyMappings}}
{{#x-property-mappings}}
private static final Map<String, String> propertyMappings = new Map<String, String>{
{{#propertyMappings}}
{{#x-property-mappings}}
'{{externalName}}' => '{{internalName}}'{{^-last}},{{/-last}}
{{/propertyMappings}}
{{/x-property-mappings}}
};
public Map<String, String> getPropertyMappings() {
return propertyMappings;
}
{{/hasPropertyMappings}}
{{#hasDefaultValues}}
{{/x-property-mappings}}
{{#x-has-default-values}}
public {{classname}}() {
{{#vars}}
{{#defaultValue}}
@@ -55,7 +55,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{#interfac
{{/vars}}
}
{{/hasDefaultValues}}
{{/x-has-default-values}}
{{/vendorExtensions}}
public static {{classname}} getExample() {
{{classname}} {{classVarName}} = new {{classname}}();

View File

@@ -40,11 +40,11 @@ class {{classname}} extends ApiClient with _${{classname}}Client {
{{#vendorExtensions}}
{{#formParams}}
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsFormField() {{/isForm}}{{#isMultipart}}@AsMultipartField() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
{{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsFormField() {{/x-is-form}}{{#x-is-multipart}}@AsMultipartField() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
{{/formParams}}
{{#bodyParam}}
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
{{^isProto}}{{^isJson}}{{^isForm}}{{^isMultipart}}@AsBody(){{/isMultipart}}{{/isForm}}{{/isJson}}{{/isProto}} {{#isProto}}@Serialized(MimeTypes.binary) {{/isProto}}{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsForm() {{/isForm}}{{#isMultipart}}@AsMultipart() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
{{^x-is-proto}}{{^x-is-json}}{{^x-is-form}}{{^x-is-multipart}}@AsBody(){{/x-is-multipart}}{{/x-is-form}}{{/x-is-json}}{{/x-is-proto}} {{#x-is-proto}}@Serialized(MimeTypes.binary) {{/x-is-proto}}{{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsForm() {{/x-is-form}}{{#x-is-multipart}}@AsMultipart() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
{{/bodyParam}}
{{/vendorExtensions}}
) {

View File

@@ -22,10 +22,10 @@ class {{classname}} {
{{classname}}(
{{#vars}}{{^defaultValue}}{{#required}} this.{{name}}, {{/required}}{{/defaultValue}}{{/vars}}
{{#vendorExtensions}}{{#hasVars}}{
{{#vendorExtensions}}{{#x-has-vars}}{
{{#vars}}{{^required}} this.{{name}}{{#defaultValue}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}}
{{#required}} {{#defaultValue}}this.{{name}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}}{{/vars}}
}{{/hasVars}}{{/vendorExtensions}}
}{{/x-has-vars}}{{/vendorExtensions}}
);
@override

View File

@@ -195,7 +195,7 @@ instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P
{{#x-hasUnknownMimeTypes}}
-- * Custom Mime Types
{{#x-unknownMimeTypes}}-- ** {{{x-mediaDataType}}}
{{#x-unknown-mime-types}}-- ** {{{x-mediaDataType}}}
data {{{x-mediaDataType}}} = {{{x-mediaDataType}}} deriving (P.Typeable)
@@ -207,4 +207,4 @@ instance A.FromJSON a => MimeUnrender {{{x-mediaDataType}}} a where mimeUnrender
-- instance MimeRender {{{x-mediaDataType}}} T.Text where mimeRender _ = undefined
-- instance MimeUnrender {{{x-mediaDataType}}} T.Text where mimeUnrender _ = undefined
{{/x-unknownMimeTypes}}{{/x-hasUnknownMimeTypes}}
{{/x-unknown-mime-types}}{{/x-hasUnknownMimeTypes}}

View File

@@ -58,8 +58,8 @@ import qualified Prelude as P
-- * Parameter newtypes
{{#x-allUniqueParams}}{{#x-newtype}}
-- ** {{{x-paramNameType}}}
newtype {{{x-paramNameType}}} = {{{x-paramNameType}}} { un{{{x-paramNameType}}} :: {{{x-dataType}}} } deriving (P.Eq, P.Show{{#x-isBodyParam}}, A.ToJSON{{/x-isBodyParam}}){{/x-newtype}}{{/x-allUniqueParams}}
-- ** {{{x-param-name-type}}}
newtype {{{x-param-name-type}}} = {{{x-param-name-type}}} { un{{{x-param-name-type}}} :: {{{x-data-type}}} } deriving (P.Eq, P.Show{{#x-isBodyParam}}, A.ToJSON{{/x-isBodyParam}}){{/x-newtype}}{{/x-allUniqueParams}}
-- * Models
@@ -125,30 +125,30 @@ mk{{classname}} {{#vars}}{{#required}}{{name}} {{/required}}{{/vars}}=
{{#x-hasEnumSection}}-- * Enums
{{#x-allUniqueParams}}{{#x-enum}}
-- ** {{{x-paramNameType}}}
-- ** {{{x-param-name-type}}}
-- | Enum of '{{{x-dataType}}}'{{#description}} .
-- | Enum of '{{{x-data-type}}}'{{#description}} .
-- {{{.}}}{{/description}}
data {{{x-paramNameType}}}
data {{{x-param-name-type}}}
= {{#allowableValues}}{{#enumVars}}{{{name}}} -- ^ @{{{value}}}@
{{^-last}}| {{/-last}}{{#-last}}deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum){{/-last}}{{/enumVars}}{{/allowableValues}}
instance A.ToJSON {{{x-paramNameType}}} where toJSON = A.toJSON . from{{{x-paramNameType}}}
instance A.FromJSON {{{x-paramNameType}}} where parseJSON o = P.either P.fail (pure . P.id) . to{{{x-paramNameType}}} =<< A.parseJSON o
instance WH.ToHttpApiData {{{x-paramNameType}}} where toQueryParam = WH.toQueryParam . from{{{x-paramNameType}}}
instance WH.FromHttpApiData {{{x-paramNameType}}} where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . to{{{x-paramNameType}}}
instance MimeRender MimeMultipartFormData {{{x-paramNameType}}} where mimeRender _ = mimeRenderDefaultMultipartFormData
instance A.ToJSON {{{x-param-name-type}}} where toJSON = A.toJSON . from{{{x-param-name-type}}}
instance A.FromJSON {{{x-param-name-type}}} where parseJSON o = P.either P.fail (pure . P.id) . to{{{x-param-name-type}}} =<< A.parseJSON o
instance WH.ToHttpApiData {{{x-param-name-type}}} where toQueryParam = WH.toQueryParam . from{{{x-param-name-type}}}
instance WH.FromHttpApiData {{{x-param-name-type}}} where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . to{{{x-param-name-type}}}
instance MimeRender MimeMultipartFormData {{{x-param-name-type}}} where mimeRender _ = mimeRenderDefaultMultipartFormData
-- | unwrap '{{{x-paramNameType}}}' enum
from{{{x-paramNameType}}} :: {{{x-paramNameType}}} -> {{{x-dataType}}}
from{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}}
-- | unwrap '{{{x-param-name-type}}}' enum
from{{{x-param-name-type}}} :: {{{x-param-name-type}}} -> {{{x-data-type}}}
from{{{x-param-name-type}}} = \case{{#allowableValues}}{{#enumVars}}
{{{name}}} -> {{{value}}}{{/enumVars}}{{/allowableValues}}
-- | parse '{{{x-paramNameType}}}' enum
to{{{x-paramNameType}}} :: {{{x-dataType}}} -> P.Either String {{{x-paramNameType}}}
to{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}}
-- | parse '{{{x-param-name-type}}}' enum
to{{{x-param-name-type}}} :: {{{x-data-type}}} -> P.Either String {{{x-param-name-type}}}
to{{{x-param-name-type}}} = \case{{#allowableValues}}{{#enumVars}}
{{{value}}} -> P.Right {{{name}}}{{/enumVars}}{{/allowableValues}}
s -> P.Left $ "to{{{x-paramNameType}}}: enum parse failure: " P.++ P.show s
s -> P.Left $ "to{{{x-param-name-type}}}: enum parse failure: " P.++ P.show s
{{/x-enum}}{{/x-allUniqueParams}}{{/x-hasEnumSection}}
{{#authMethods}}{{#-first}}-- * Auth Methods

View File

@@ -123,6 +123,6 @@ gen{{classname}} n =
{{#x-allUniqueParams}}{{#x-enum}}
instance Arbitrary {{{x-paramNameType}}} where
instance Arbitrary {{{x-param-name-type}}} where
arbitrary = arbitraryBoundedEnum
{{/x-enum}}{{/x-allUniqueParams}}

View File

@@ -12,34 +12,34 @@ CREATE DATABASE IF NOT EXISTS `{{{defaultDatabaseName}}}` DEFAULT CHARACTER SET
-- --------------------------------------------------------
{{#models}}{{#model}}{{#hasVars}}{{^isArrayModel}}--
-- Table structure{{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}} for table `{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} generated from model '{{classVarName}}'
-- Table structure{{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}} for table `{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} generated from model '{{classVarName}}'
{{#description}}
-- {{description}}
{{/description}}
--
{{#vendorExtensions}}
{{#x-mysqlSchema}}
{{#x-mysql-schema}}
{{#tableDefinition}}
CREATE TABLE IF NOT EXISTS {{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}` (
{{/tableDefinition}}
{{/x-mysqlSchema}}
{{/x-mysql-schema}}
{{/vendorExtensions}}
{{#vars}}
{{#vendorExtensions}}
{{#x-mysqlSchema}}
{{#x-mysql-schema}}
{{#columnDefinition}}
`{{colName}}` {{colDataType}}{{#colDataTypeArguments}}{{#-first}}({{/-first}}{{#isString}}'{{/isString}}{{argumentValue}}{{#isString}}'{{/isString}}{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/colDataTypeArguments}}{{#colUnsigned}} UNSIGNED{{/colUnsigned}}{{#colNotNull}} NOT NULL{{/colNotNull}}{{#colDefault}} DEFAULT {{#isString}}'{{defaultValue}}'{{/isString}}{{^isString}}{{defaultValue}}{{/isString}}{{/colDefault}}{{#colComment}} COMMENT '{{colComment}}'{{/colComment}}{{^-last}},{{/-last}}
{{/columnDefinition}}
{{/x-mysqlSchema}}
{{/x-mysql-schema}}
{{/vendorExtensions}}
{{/vars}}
{{#vendorExtensions}}
{{#x-mysqlSchema}}
{{#x-mysql-schema}}
{{#tableDefinition}}
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci{{#tblComment}} COMMENT='{{tblComment}}'{{/tblComment}};
{{/tableDefinition}}
{{/x-mysqlSchema}}
{{/x-mysql-schema}}
{{/vendorExtensions}}
{{/isArrayModel}}{{/hasVars}}{{/model}}{{/models}}

View File

@@ -6,22 +6,22 @@
{{#models}}{{#model}}
--
-- SELECT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}
-- SELECT template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}
--
SELECT {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 1;
SELECT {{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}} FROM {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} WHERE 1;
--
-- INSERT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}
-- INSERT template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}
--
INSERT INTO {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}}) VALUES ({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}{{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}});
INSERT INTO {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}({{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}}) VALUES ({{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}{{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}});
--
-- UPDATE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}
-- UPDATE template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}
--
UPDATE {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} SET {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}` = {{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} WHERE 1;
UPDATE {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} SET {{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}` = {{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}} WHERE 1;
--
-- DELETE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}
-- DELETE template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}
--
DELETE FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 0;
DELETE FROM {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} WHERE 0;
{{/model}}{{/models}}

View File

@@ -1 +1 @@
{{#isEnum}}JsonSupport.unwrap Enums.{{{datatypeWithEnum}}}_of_yojson{{/isEnum}}{{^isEnum}}{{#returnType}}{{#returnTypeIsPrimitive}}JsonSupport.to_{{{returnBaseType}}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#vendorExtensions.x-modelModule}}JsonSupport.unwrap {{{vendorExtensions.x-modelModule}}}.of_yojson{{/vendorExtensions.x-modelModule}}{{^vendorExtensions.x-modelModule}}JsonSupport.unwrap {{{returnBaseType}}}.of_yojson{{/vendorExtensions.x-modelModule}}{{/returnTypeIsPrimitive}}{{/returnType}}{{/isEnum}}
{{#isEnum}}JsonSupport.unwrap Enums.{{{datatypeWithEnum}}}_of_yojson{{/isEnum}}{{^isEnum}}{{#returnType}}{{#returnTypeIsPrimitive}}JsonSupport.to_{{{returnBaseType}}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#vendorExtensions.x-model-module}}JsonSupport.unwrap {{{vendorExtensions.x-model-module}}}.of_yojson{{/vendorExtensions.x-model-module}}{{^vendorExtensions.x-model-module}}JsonSupport.unwrap {{{returnBaseType}}}.of_yojson{{/vendorExtensions.x-model-module}}{{/returnTypeIsPrimitive}}{{/returnType}}{{/isEnum}}

View File

@@ -1 +1 @@
{{#isListContainer}}{{#items}}(JsonSupport.of_list_of {{> to_json}}){{/items}}{{/isListContainer}}{{#isMapContainer}}{{#items}}(JsonSupport.of_map_of {{> to_json}}){{/items}}{{/isMapContainer}}{{#isString}}JsonSupport.of_string{{/isString}}{{#isLong}}JsonSupport.of_int64{{/isLong}}{{#isInteger}}JsonSupport.of_int32{{/isInteger}}{{#isFloat}}JsonSupport.of_float{{/isFloat}}{{#isNumber}}JsonSupport.of_float{{/isNumber}}{{#isDouble}}JsonSupport.of_float{{/isDouble}}{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}{{^isEnum}}{{#isModel}}{{#vendorExtensions.x-modelModule}}{{{vendorExtensions.x-modelModule}}}.to_yojson{{/vendorExtensions.x-modelModule}}{{^vendorExtensions.x-modelModule}}{{{baseType}}}.to_yojson{{/vendorExtensions.x-modelModule}}{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.{{{datatypeWithEnum}}}_to_yojson{{/isEnum}}{{/isContainer}}{{/isModel}}
{{#isListContainer}}{{#items}}(JsonSupport.of_list_of {{> to_json}}){{/items}}{{/isListContainer}}{{#isMapContainer}}{{#items}}(JsonSupport.of_map_of {{> to_json}}){{/items}}{{/isMapContainer}}{{#isString}}JsonSupport.of_string{{/isString}}{{#isLong}}JsonSupport.of_int64{{/isLong}}{{#isInteger}}JsonSupport.of_int32{{/isInteger}}{{#isFloat}}JsonSupport.of_float{{/isFloat}}{{#isNumber}}JsonSupport.of_float{{/isNumber}}{{#isDouble}}JsonSupport.of_float{{/isDouble}}{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}{{^isEnum}}{{#isModel}}{{#vendorExtensions.x-model-module}}{{{vendorExtensions.x-model-module}}}.to_yojson{{/vendorExtensions.x-model-module}}{{^vendorExtensions.x-model-module}}{{{baseType}}}.to_yojson{{/vendorExtensions.x-model-module}}{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.{{{datatypeWithEnum}}}_to_yojson{{/isEnum}}{{/isContainer}}{{/isModel}}

View File

@@ -1 +1 @@
{{#isContainer}}{{#items}}(List.map {{> to_string}}){{/items}}{{/isContainer}}{{^isEnum}}{{#isLong}}Int64.to_string{{/isLong}}{{#isInteger}}Int32.to_string{{/isInteger}}{{#isFloat}}string_of_float{{/isFloat}}{{#isNumber}}string_of_float{{/isNumber}}{{#isDouble}}string_of_float{{/isDouble}}{{#isBoolean}}string_of_bool{{/isBoolean}}{{#isFile}}(fun x -> x){{/isFile}}{{#isDate}}(fun x -> x){{/isDate}}{{#isDateTime}}(fun x -> x){{/isDateTime}}{{#isString}}(fun x -> x){{/isString}}{{#isByteArray}}(fun x -> x){{/isByteArray}}{{#isModel}}{{{vendorExtensions.x-modelModule}}}.show{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}{{/isContainer}}{{/isModel}}
{{#isContainer}}{{#items}}(List.map {{> to_string}}){{/items}}{{/isContainer}}{{^isEnum}}{{#isLong}}Int64.to_string{{/isLong}}{{#isInteger}}Int32.to_string{{/isInteger}}{{#isFloat}}string_of_float{{/isFloat}}{{#isNumber}}string_of_float{{/isNumber}}{{#isDouble}}string_of_float{{/isDouble}}{{#isBoolean}}string_of_bool{{/isBoolean}}{{#isFile}}(fun x -> x){{/isFile}}{{#isDate}}(fun x -> x){{/isDate}}{{#isDateTime}}(fun x -> x){{/isDateTime}}{{#isString}}(fun x -> x){{/isString}}{{#isByteArray}}(fun x -> x){{/isByteArray}}{{#isModel}}{{{vendorExtensions.x-model-module}}}.show{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}{{/isContainer}}{{/isModel}}

View File

@@ -68,9 +68,9 @@ To run a client, follow one of the following simple steps:
{{#operations}}
{{#operation}}
{{#vendorExtensions}}
{{^noClientExample}}
{{^x-no-client-example}}
cargo run --example client {{{operationId}}}
{{/noClientExample}}
{{/x-no-client-example}}
{{/vendorExtensions}}
{{/operation}}
{{/operations}}

View File

@@ -58,7 +58,7 @@ impl<T> RequestParser<T> for ApiRequestParser {
{{#urls}}
{{#requests}}
// {{{operationId}}} - {{{httpMethod}}} {{{path}}}
&hyper::Method::{{{vendorExtensions.HttpMethod}}} if path.matched(paths::ID_{{{vendorExtensions.PATH_ID}}}) => Ok("{{{operationId}}}"),
&hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Ok("{{{operationId}}}"),
{{/requests}}
{{/urls}}
{{/callbacks}}

View File

@@ -1,9 +1,9 @@
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}}: String,
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
param_{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -23,9 +23,9 @@
,{{{paramName}}}=utf8_percent_encode(&param_{{{paramName}}}.to_string(), ID_ENCODE_SET)
{{/pathParams}}
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
,{{.}}=callback_{{.}}
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
);
@@ -65,7 +65,7 @@
};
let mut request = match Request::builder()
.method("{{{vendorExtensions.HttpMethod}}}")
.method("{{{vendorExtensions.x-http-method}}}")
.uri(uri)
.body(Body::empty()) {
Ok(req) => req,
@@ -73,7 +73,7 @@
};
{{#vendorExtensions}}
{{#consumesMultipart}}
{{#x-consumes-multipart}}
let (body_string, multipart_header) = {
let mut multipart = Multipart::new();
@@ -139,10 +139,10 @@
Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", multipart_header, e)))
});
{{/consumesMultipart}}
{{^consumesMultipart}}
{{/x-consumes-multipart}}
{{^x-consumes-multipart}}
{{#vendorExtensions}}
{{^consumesMultipartRelated}}
{{^x-consumes-multipart-related}}
{{#formParams}}
{{#-first}}
let params = &[
@@ -160,8 +160,8 @@
*request.body_mut() = Body::from(body.into_bytes());
{{/-last}}
{{/formParams}}
{{/consumesMultipartRelated}}
{{#consumesMultipartRelated}}
{{/x-consumes-multipart-related}}
{{#x-consumes-multipart-related}}
{{#formParams}}
{{#-first}}
// Construct the Body for a multipart/related request. The mime 0.2.6 library
@@ -223,37 +223,37 @@
{{/-last}}
{{/formParams}}
{{/consumesMultipartRelated}}
{{/x-consumes-multipart-related}}
{{/vendorExtensions}}
{{#bodyParam}}
{{#-first}}
// Body parameter
{{/-first}}
{{#vendorExtensions}}
{{#consumesPlainText}}
{{#x-consumes-plain-text}}
{{#isByteArray}}
let body = param_{{{paramName}}}.0;
{{/isByteArray}}
{{^isByteArray}}
let body = param_{{{paramName}}};
{{/isByteArray}}
{{/consumesPlainText}}
{{/x-consumes-plain-text}}
{{#required}}
{{#consumesXml}}
{{#x-consumes-xml}}
let body = param_{{{paramName}}}.to_xml();
{{/consumesXml}}
{{#consumesJson}}
{{/x-consumes-xml}}
{{#x-consumes-json}}
let body = serde_json::to_string(&param_{{{paramName}}}).expect("impossible to fail to serialize");
{{/consumesJson}}
{{/x-consumes-json}}
{{/required}}
{{^required}}
let body = param_{{{paramName}}}.map(|ref body| {
{{#consumesXml}}
{{#x-consumes-xml}}
body.to_xml()
{{/consumesXml}}
{{#consumesJson}}
{{/x-consumes-xml}}
{{#x-consumes-json}}
serde_json::to_string(body).expect("impossible to fail to serialize")
{{/consumesJson}}
{{/x-consumes-json}}
});
{{/required}}
{{/vendorExtensions}}
@@ -279,7 +279,7 @@
{{/-last}}
{{/bodyParam}}
{{/consumesMultipart}}
{{/x-consumes-multipart}}
{{/vendorExtensions}}
let header = HeaderValue::from_str(Has::<XSpanIdString>::get(context).0.clone().to_string().as_str());
request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header {
@@ -393,27 +393,27 @@
.to_raw()
.map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?;
{{#vendorExtensions}}
{{#producesBytes}}
{{#x-produces-bytes}}
let body = swagger::ByteArray(body.to_vec());
{{/producesBytes}}
{{^producesBytes}}
{{/x-produces-bytes}}
{{^x-produces-bytes}}
let body = str::from_utf8(&body)
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
{{#producesXml}}
{{#x-produces-xml}}
// ToDo: this will move to swagger-rs and become a standard From conversion trait
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
let body = serde_xml_rs::from_str::<{{{dataType}}}>(body)
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?;
{{/producesXml}}
{{#producesJson}}
{{/x-produces-xml}}
{{#x-produces-json}}
let body = serde_json::from_str::<{{{dataType}}}>(body)?;
{{/producesJson}}
{{#producesPlainText}}
{{/x-produces-json}}
{{#x-produces-plain-text}}
let body = body.to_string();
{{/producesPlainText}}
{{/producesBytes}}
{{/x-produces-plain-text}}
{{/x-produces-bytes}}
{{/vendorExtensions}}
Ok({{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}
Ok({{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}}
{{^headers}}
(body)
{{/headers}}
@@ -431,7 +431,7 @@
{{/dataType}}
{{^dataType}}
Ok(
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}
{{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}}
{{#headers}}
{{#-first}}
{

View File

@@ -43,9 +43,9 @@ fn main() {
{{#operations}}
{{#operation}}
{{#vendorExtensions}}
{{^noClientExample}}
{{^x-no-client-example}}
"{{{operationId}}}",
{{/noClientExample}}
{{/x-no-client-example}}
{{/vendorExtensions}}
{{/operation}}
{{/operations}}
@@ -104,22 +104,22 @@ fn main() {
{{#operations}}
{{#operation}}
{{#vendorExtensions}}
{{#noClientExample}}
{{#x-no-client-example}}
/* Disabled because there's no example.
{{/noClientExample}}
{{/x-no-client-example}}
{{/vendorExtensions}}
Some("{{{operationId}}}") => {
let result = rt.block_on(client.{{{vendorExtensions.operation_id}}}(
let result = rt.block_on(client.{{{vendorExtensions.x-operation-id}}}(
{{#allParams}}
{{{vendorExtensions.example}}}{{^-last}},{{/-last}}
{{{vendorExtensions.x-example}}}{{^-last}},{{/-last}}
{{/allParams}}
));
info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
},
{{#vendorExtensions}}
{{#noClientExample}}
{{#x-no-client-example}}
*/
{{/noClientExample}}
{{/x-no-client-example}}
{{/vendorExtensions}}
{{/operation}}
{{/operations}}

View File

@@ -1,12 +1,12 @@
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}}: String,
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -14,6 +14,6 @@
context: &C) -> Result<{{{operationId}}}Response, ApiError>
{
let context = context.clone();
info!("{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}({{#allParams}}{{#vendorExtensions}}{{{formatString}}}{{/vendorExtensions}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) - X-Span-ID: {:?}"{{#allParams}}, {{{paramName}}}{{/allParams}}, context.get().0.clone());
info!("{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}({{#allParams}}{{#vendorExtensions}}{{{x-format-string}}}{{/vendorExtensions}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) - X-Span-ID: {:?}"{{#allParams}}, {{{paramName}}}{{/allParams}}, context.get().0.clone());
Err("Generic failuare".into())
}

View File

@@ -36,7 +36,7 @@ pub trait Api<C: Send + Sync> {
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -64,7 +64,7 @@ pub trait ApiNoContext<C: Send + Sync> {
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -107,7 +107,7 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -115,7 +115,7 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
) -> Result<{{{operationId}}}Response, ApiError>
{
let context = self.context().clone();
self.api().{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}({{#allParams}}{{{paramName}}}, {{/allParams}}&context).await
self.api().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}({{#allParams}}{{{paramName}}}, {{/allParams}}&context).await
}
{{/operation}}
@@ -159,12 +159,12 @@ pub trait CallbackApi<C: Send + Sync> {
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}}: String,
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -197,12 +197,12 @@ pub trait CallbackApiNoContext<C: Send + Sync> {
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}}: String,
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -250,12 +250,12 @@ impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackApiNoConte
{{#summary}}
/// {{{summary}}}
{{/summary}}
async fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
&self,
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}}: String,
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}},
@@ -263,11 +263,11 @@ impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackApiNoConte
) -> Result<{{{operationId}}}Response, ApiError>
{
let context = self.context().clone();
self.api().{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
self.api().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}},
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
{{{paramName}}},

View File

@@ -159,25 +159,25 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
}
{{#arrayModelType}}{{#vendorExtensions}}{{#itemXmlName}}// Utility function for wrapping list elements when serializing xml
{{#arrayModelType}}{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml
#[allow(non_snake_case)]
fn wrap_in_{{{itemXmlName}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
fn wrap_in_{{{x-item-xml-name}}}<S>(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serde_xml_rs::wrap_primitives(item, serializer, "{{{itemXmlName}}}")
serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}")
}
{{/itemXmlName}}
{{/x-item-xml-name}}
{{/vendorExtensions}}
{{! vec}}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct {{{classname}}}(
{{#vendorExtensions}}
{{#itemXmlName}}
#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]
{{/itemXmlName}}
{{#x-item-xml-name}}
#[serde(serialize_with = "wrap_in_{{{x-item-xml-name}}}")]
{{/x-item-xml-name}}
{{/vendorExtensions}}
Vec<{{{arrayModelType}}}>
);
@@ -277,9 +277,9 @@ pub struct {{{classname}}} {
{{/isEnum}}
#[serde(rename = "{{{baseName}}}")]
{{#vendorExtensions}}
{{#itemXmlName}}
#[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")]
{{/itemXmlName}}
{{#x-item-xml-name}}
#[serde(serialize_with = "wrap_in_{{{x-item-xml-name}}}")]
{{/x-item-xml-name}}
{{/vendorExtensions}}
{{#required}}
pub {{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}},
@@ -478,4 +478,4 @@ impl {{{classname}}} {
}
{{/usesXml}}
{{/model}}
{{/models}}
{{/models}}

View File

@@ -1,13 +1,13 @@
#[derive(Debug, PartialEq)]
{{#vendorExtensions.x-mustUseResponse}}
{{#vendorExtensions.x-must-use-response}}
#[must_use]
{{/vendorExtensions.x-mustUseResponse}}
{{/vendorExtensions.x-must-use-response}}
pub enum {{{operationId}}}Response {
{{#responses}}
{{#message}}
/// {{{message}}}{{/message}}
{{#vendorExtensions}}
{{{x-responseId}}}
{{{x-response-id}}}
{{/vendorExtensions}}
{{^dataType}}
{{#hasHeaders}}
@@ -17,23 +17,23 @@ pub enum {{{operationId}}}Response {
{{#dataType}}
{{^hasHeaders}}
{{#vendorExtensions}}
{{#producesPlainText}}
{{#x-produces-plain-text}}
(String)
{{/producesPlainText}}
{{^producesPlainText}}
{{/x-produces-plain-text}}
{{^x-produces-plain-text}}
({{{dataType}}})
{{/producesPlainText}}
{{/x-produces-plain-text}}
{{/vendorExtensions}}
{{/hasHeaders}}
{{#hasHeaders}}
{
{{#vendorExtensions}}
{{#producesPlainText}}
{{#x-produces-plain-text}}
body: String,
{{/producesPlainText}}
{{^producesPlainText}}
{{/x-produces-plain-text}}
{{^x-produces-plain-text}}
body: {{{dataType}}},
{{/producesPlainText}}
{{/x-produces-plain-text}}
{{/vendorExtensions}}
{{/hasHeaders}}
{{/dataType}}

View File

@@ -38,7 +38,7 @@
{{/hasAuthMethods}}
{{#vendorExtensions}}
{{#consumesMultipart}}
{{#x-consumes-multipart}}
let boundary = match swagger::multipart::boundary(&headers) {
Some(boundary) => boundary.to_string(),
None => return Ok(Response::builder()
@@ -47,8 +47,8 @@
.expect("Unable to create Bad Request response for incorrect boundary")),
};
{{/consumesMultipart}}
{{#hasPathParams}}
{{/x-consumes-multipart}}
{{#x-has-path-params}}
// Path parameters
let path: &str = &uri.path().to_string();
let path_params =
@@ -58,7 +58,7 @@
panic!("Path {} matched RE {{{x-path-id}}} in set but failed match against \"{}\"", path, paths::REGEX_{{{x-path-id}}}.as_str())
);
{{/hasPathParams}}
{{/x-has-path-params}}
{{/vendorExtensions}}
{{#pathParams}}
let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() {
@@ -77,9 +77,9 @@
{{/pathParams}}
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
let callback_{{.}} = path_params["{{{.}}}"].to_string();
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#headerParams}}
{{#-first}}
@@ -163,7 +163,7 @@
{{/-last}}
{{/queryParams}}
{{#vendorExtensions}}
{{^consumesMultipart}}
{{^x-consumes-multipart}}
{{#bodyParams}}
{{#-first}}
// Body parameters (note that non-required body parameters will ignore garbage
@@ -173,17 +173,17 @@
match result {
Ok(body) => {
{{#vendorExtensions}}
{{^consumesPlainText}}
{{^x-consumes-plain-text}}
let mut unused_elements = Vec::new();
{{/consumesPlainText}}
{{/x-consumes-plain-text}}
let param_{{{paramName}}}: Option<{{{dataType}}}> = if !body.is_empty() {
{{#consumesXml}}
{{#x-consumes-xml}}
let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body);
{{/consumesXml}}
{{#consumesJson}}
{{/x-consumes-xml}}
{{#x-consumes-json}}
let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
{{/consumesJson}}
{{^consumesPlainText}}
{{/x-consumes-json}}
{{^x-consumes-plain-text}}
match serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
@@ -199,8 +199,8 @@
Err(_) => None,
{{/required}}
}
{{/consumesPlainText}}
{{#consumesPlainText}}
{{/x-consumes-plain-text}}
{{#x-consumes-plain-text}}
{{#isByteArray}}
Some(swagger::ByteArray(body.to_vec()))
{{/isByteArray}}
@@ -213,7 +213,7 @@
.expect("Unable to create Bad Request response for invalid body parameter {{{baseName}}} due to UTF-8")),
}
{{/isString}}
{{/consumesPlainText}}
{{/x-consumes-plain-text}}
{{/vendorExtensions}}
} else {
None
@@ -232,8 +232,8 @@
{{/-last}}
{{/bodyParams}}
{{/consumesMultipart}}
{{#consumesMultipart}}
{{/x-consumes-multipart}}
{{#x-consumes-multipart}}
{{^bodyParams}}
{{#vendorExtensions}}
// Form Body parameters (note that non-required body parameters will ignore garbage
@@ -306,25 +306,25 @@
{{/formParams}}
{{/vendorExtensions}}
{{/bodyParams}}
{{/consumesMultipart}}
{{^consumesMultipartRelated}}
{{^consumesMultipart}}
{{/x-consumes-multipart}}
{{^x-consumes-multipart-related}}
{{^x-consumes-multipart}}
{{^bodyParams}}
{{#vendorExtensions}}
{{#formParams}}
{{#-first}}
// Form parameters
{{/-first}}
let param_{{{paramName}}} = {{^isContainer}}{{#vendorExtensions}}{{{example}}};{{/vendorExtensions}}{{/isContainer}}{{#isListContainer}}{{#required}}Vec::new();{{/required}}{{^required}}None;{{/required}}{{/isListContainer}}{{#isMapContainer}}None;{{/isMapContainer}}
let param_{{{paramName}}} = {{^isContainer}}{{#vendorExtensions}}{{{x-example}}};{{/vendorExtensions}}{{/isContainer}}{{#isListContainer}}{{#required}}Vec::new();{{/required}}{{^required}}None;{{/required}}{{/isListContainer}}{{#isMapContainer}}None;{{/isMapContainer}}
{{#-last}}
{{/-last}}
{{/formParams}}
{{/vendorExtensions}}
{{/bodyParams}}
{{/consumesMultipart}}
{{/consumesMultipartRelated}}
{{#consumesMultipartRelated}}
{{/x-consumes-multipart}}
{{/x-consumes-multipart-related}}
{{#x-consumes-multipart-related}}
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
@@ -432,13 +432,13 @@
{{/-last}}
{{/formParams}}
{{/consumesMultipartRelated}}
{{/x-consumes-multipart-related}}
{{/vendorExtensions}}
let result = api_impl.{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(
let result = api_impl.{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}(
{{#vendorExtensions}}
{{#callbackParams}}
{{#x-callback-params}}
callback_{{.}},
{{/callbackParams}}
{{/x-callback-params}}
{{/vendorExtensions}}
{{#allParams}}
param_{{{paramName}}}{{#isListContainer}}.as_ref(){{/isListContainer}},
@@ -453,7 +453,7 @@
{{#bodyParams}}
{{#vendorExtensions}}
{{^consumesPlainText}}
{{^x-consumes-plain-text}}
if !unused_elements.is_empty() {
response.headers_mut().insert(
HeaderName::from_static("warning"),
@@ -461,13 +461,13 @@
.expect("Unable to create Warning header value"));
}
{{/consumesPlainText}}
{{/x-consumes-plain-text}}
{{/vendorExtensions}}
{{/bodyParams}}
match result {
Ok(rsp) => match rsp {
{{#responses}}
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}
{{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}}
{{#dataType}}
{{^headers}}
(body)
@@ -520,35 +520,35 @@
{{#vendorExtensions}}
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("{{{mimeType}}}")
.expect("Unable to create Content-Type header for {{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}"));
HeaderValue::from_str("{{{x-mime-type}}}")
.expect("Unable to create Content-Type header for {{{x-uppercase-operation-id}}}_{{x-uppercase-response-id}}"));
{{/vendorExtensions}}
{{/dataType}}
{{/-first}}
{{/produces}}
{{#dataType}}
{{#vendorExtensions}}
{{#producesXml}}
{{^has_namespace}}
{{#x-produces-xml}}
{{^x-has-namespace}}
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
{{/has_namespace}}
{{#has_namespace}}
{{/x-has-namespace}}
{{#x-has-namespace}}
let mut namespaces = std::collections::BTreeMap::new();
// An empty string is used to indicate a global namespace in xmltree.
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
{{/has_namespace}}
{{/producesXml}}
{{#producesJson}}
{{/x-has-namespace}}
{{/x-produces-xml}}
{{#x-produces-json}}
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
{{/producesJson}}
{{#producesBytes}}
{{/x-produces-json}}
{{#x-produces-bytes}}
let body = body.0;
{{/producesBytes}}
{{#producesPlainText}}
{{/x-produces-bytes}}
{{#x-produces-plain-text}}
let body = body;
{{/producesPlainText}}
{{/x-produces-plain-text}}
{{/vendorExtensions}}
*response.body_mut() = Body::from(body);
{{/dataType}}
@@ -565,20 +565,20 @@
Ok(response)
{{#vendorExtensions}}
{{^consumesMultipart}}
{{^x-consumes-multipart}}
{{^bodyParams}}
{{#vendorExtensions}}
{{#consumesMultipartRelated}}
{{#x-consumes-multipart-related}}
},
Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter {{{baseName}}}: {}", e)))
.expect("Unable to create Bad Request response due to unable to read body parameter {{{baseName}}}")),
}
{{/consumesMultipartRelated}}
{{/x-consumes-multipart-related}}
{{/vendorExtensions}}
{{/bodyParams}}
{{/consumesMultipart}}
{{/x-consumes-multipart}}
{{/vendorExtensions}}
{{#bodyParams}}
{{#-first}}
@@ -591,7 +591,7 @@
{{/-first}}
{{/bodyParams}}
{{#vendorExtensions}}
{{#consumesMultipart}}
{{#x-consumes-multipart}}
{{^bodyParams}}
{{#vendorExtensions}}
},
@@ -602,6 +602,6 @@
}
{{/vendorExtensions}}
{{/bodyParams}}
{{/consumesMultipart}}
{{/x-consumes-multipart}}
{{/vendorExtensions}}
},

View File

@@ -24,7 +24,7 @@ pub enum {{classname}} {
#[serde(tag = "{{{vendorExtensions.x-tag-name}}}")]
pub enum {{classname}} {
{{#vendorExtensions}}
{{#mappedModels}}
{{#x-mapped-models}}
#[serde(rename="{{mappingName}}")]
{{modelName}} {
{{#vars}}
@@ -35,7 +35,7 @@ pub enum {{classname}} {
{{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
{{/vars}}
},
{{/mappedModels}}
{{/x-mapped-models}}
{{/vendorExtensions}}
}

View File

@@ -38,14 +38,14 @@ public abstract class AbstractIntegrationTest {
protected Boolean generateMetadata = true;
protected Map<String, String> systemPropertyOverrides = new HashMap<>();
protected Map<String, String> globalPropertyOverrides = new HashMap<>();
// @wing328: ignore for the time being until we fix the error with the integration test
@Test(enabled = false)
public void generatesCorrectDirectoryStructure() throws IOException {
DefaultGenerator codeGen = new DefaultGenerator();
codeGen.setGenerateMetadata(generateMetadata);
for (Map.Entry<String, String> propertyOverride : systemPropertyOverrides.entrySet()) {
for (Map.Entry<String, String> propertyOverride : globalPropertyOverrides.entrySet()) {
codeGen.setGeneratorPropertyDefault(propertyOverride.getKey(), propertyOverride.getValue());
}

View File

@@ -19,7 +19,6 @@ package org.openapitools.codegen.config;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
import org.testng.annotations.Test;
import java.io.File;
@@ -66,7 +65,7 @@ public class CodegenConfiguratorTest {
.addImportMapping("one", "two")
.addInstantiationType("three", "four")
.addLanguageSpecificPrimitive("five")
.addSystemProperty("six", "seven")
.addGlobalProperty("six", "seven")
.addTypeMapping("eight", "nine")
.setApiPackage("test-api")
.setArtifactId("test-artifactId")

View File

@@ -53,7 +53,7 @@ public class OneOfImplementorAdditionalDataTest {
o.addToImplementor(cc, implModel, implModelImports, false);
// make sure all the additions were done correctly
Assert.assertEquals(implModel.getVendorExtensions().get("implements"), new ArrayList<String>(){{add(oneOfModel.classname);}});
Assert.assertEquals(implModel.getVendorExtensions().get("x-implements"), new ArrayList<String>(){{add(oneOfModel.classname);}});
Assert.assertEquals(implModelImports, interfaceModelImports);
Assert.assertEquals(implModel.vars, new ArrayList<CodegenProperty>(){{add(cp3); add(cp1);}});
Assert.assertTrue(implModel.vars.get(0).hasMore);

View File

@@ -14,7 +14,7 @@
"artifactVersion" : "1.2.3",
"library" : "jersey2",
"ignoreFileOverride": "/path/to/override/.openapi-generator-ignore",
"systemProperties" : {
"globalProperties" : {
"systemProp1" : "value1"
},
"instantiationTypes" : {

View File

@@ -2039,7 +2039,7 @@ toE'ArrayEnum = \case
-- ** E'EnumFormString
-- | Enum of 'Text' .
-- | Enum of 'Text' .
-- Form parameter enum test (string)
data E'EnumFormString
= E'EnumFormString'_abc -- ^ @"_abc"@
@@ -2304,7 +2304,7 @@ toE'Kind = \case
-- ** E'Status
-- | Enum of 'Text' .
-- | Enum of 'Text' .
-- Order Status
data E'Status
= E'Status'Placed -- ^ @"placed"@
@@ -2336,7 +2336,7 @@ toE'Status = \case
-- ** E'Status2
-- | Enum of 'Text' .
-- | Enum of 'Text' .
-- pet status in the store
data E'Status2
= E'Status2'Available -- ^ @"available"@

View File

@@ -32,12 +32,6 @@ docs/Foo.md
docs/FormatTest.md
docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md
docs/InlineObject.md
docs/InlineObject1.md
docs/InlineObject2.md
docs/InlineObject3.md
docs/InlineObject4.md
docs/InlineObject5.md
docs/InlineResponseDefault.md
docs/List.md
docs/MapTest.md
@@ -97,12 +91,6 @@ lib/petstore/models/foo.rb
lib/petstore/models/format_test.rb
lib/petstore/models/has_only_read_only.rb
lib/petstore/models/health_check_result.rb
lib/petstore/models/inline_object.rb
lib/petstore/models/inline_object1.rb
lib/petstore/models/inline_object2.rb
lib/petstore/models/inline_object3.rb
lib/petstore/models/inline_object4.rb
lib/petstore/models/inline_object5.rb
lib/petstore/models/inline_response_default.rb
lib/petstore/models/list.rb
lib/petstore/models/map_test.rb
@@ -157,12 +145,6 @@ spec/models/foo_spec.rb
spec/models/format_test_spec.rb
spec/models/has_only_read_only_spec.rb
spec/models/health_check_result_spec.rb
spec/models/inline_object1_spec.rb
spec/models/inline_object2_spec.rb
spec/models/inline_object3_spec.rb
spec/models/inline_object4_spec.rb
spec/models/inline_object5_spec.rb
spec/models/inline_object_spec.rb
spec/models/inline_response_default_spec.rb
spec/models/list_spec.rb
spec/models/map_test_spec.rb

View File

@@ -141,12 +141,6 @@ Class | Method | HTTP request | Description
- [Petstore::FormatTest](docs/FormatTest.md)
- [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [Petstore::HealthCheckResult](docs/HealthCheckResult.md)
- [Petstore::InlineObject](docs/InlineObject.md)
- [Petstore::InlineObject1](docs/InlineObject1.md)
- [Petstore::InlineObject2](docs/InlineObject2.md)
- [Petstore::InlineObject3](docs/InlineObject3.md)
- [Petstore::InlineObject4](docs/InlineObject4.md)
- [Petstore::InlineObject5](docs/InlineObject5.md)
- [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md)
- [Petstore::List](docs/List.md)
- [Petstore::MapTest](docs/MapTest.md)

View File

@@ -1,19 +0,0 @@
# Petstore::InlineObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | Updated name of the pet | [optional]
**status** | **String** | Updated status of the pet | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject.new(name: null,
status: null)
```

View File

@@ -1,19 +0,0 @@
# Petstore::InlineObject1
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additional_metadata** | **String** | Additional data to pass to server | [optional]
**file** | **File** | file to upload | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject1.new(additional_metadata: null,
file: null)
```

View File

@@ -1,19 +0,0 @@
# Petstore::InlineObject2
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_form_string_array** | **Array&lt;String&gt;** | Form parameter enum test (string array) | [optional]
**enum_form_string** | **String** | Form parameter enum test (string) | [optional] [default to &#39;-efg&#39;]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject2.new(enum_form_string_array: null,
enum_form_string: null)
```

View File

@@ -1,43 +0,0 @@
# Petstore::InlineObject3
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **Integer** | None | [optional]
**int32** | **Integer** | None | [optional]
**int64** | **Integer** | None | [optional]
**number** | **Float** | None |
**float** | **Float** | None | [optional]
**double** | **Float** | None |
**string** | **String** | None | [optional]
**pattern_without_delimiter** | **String** | None |
**byte** | **String** | None |
**binary** | **File** | None | [optional]
**date** | **Date** | None | [optional]
**date_time** | **DateTime** | None | [optional]
**password** | **String** | None | [optional]
**callback** | **String** | None | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject3.new(integer: null,
int32: null,
int64: null,
number: null,
float: null,
double: null,
string: null,
pattern_without_delimiter: null,
byte: null,
binary: null,
date: null,
date_time: null,
password: null,
callback: null)
```

View File

@@ -1,19 +0,0 @@
# Petstore::InlineObject4
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**param** | **String** | field1 |
**param2** | **String** | field2 |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject4.new(param: null,
param2: null)
```

View File

@@ -1,19 +0,0 @@
# Petstore::InlineObject5
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additional_metadata** | **String** | Additional data to pass to server | [optional]
**required_file** | **File** | file to upload |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject5.new(additional_metadata: null,
required_file: null)
```

View File

@@ -40,12 +40,6 @@ require 'petstore/models/foo'
require 'petstore/models/format_test'
require 'petstore/models/has_only_read_only'
require 'petstore/models/health_check_result'
require 'petstore/models/inline_object'
require 'petstore/models/inline_object1'
require 'petstore/models/inline_object2'
require 'petstore/models/inline_object3'
require 'petstore/models/inline_object4'
require 'petstore/models/inline_object5'
require 'petstore/models/inline_response_default'
require 'petstore/models/list'
require 'petstore/models/map_test'

View File

@@ -1,217 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject
# Updated name of the pet
attr_accessor :name
# Updated status of the pet
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'name' => :'name',
:'status' => :'status'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'name' => :'String',
:'status' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
name == o.name &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[name, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,217 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject1
# Additional data to pass to server
attr_accessor :additional_metadata
# file to upload
attr_accessor :file
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'additional_metadata' => :'additionalMetadata',
:'file' => :'file'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'additional_metadata' => :'String',
:'file' => :'File'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject1` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'additional_metadata')
self.additional_metadata = attributes[:'additional_metadata']
end
if attributes.key?(:'file')
self.file = attributes[:'file']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
additional_metadata == o.additional_metadata &&
file == o.file
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[additional_metadata, file].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,255 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject2
# Form parameter enum test (string array)
attr_accessor :enum_form_string_array
# Form parameter enum test (string)
attr_accessor :enum_form_string
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'enum_form_string_array' => :'enum_form_string_array',
:'enum_form_string' => :'enum_form_string'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'enum_form_string_array' => :'Array<String>',
:'enum_form_string' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject2` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'enum_form_string_array')
if (value = attributes[:'enum_form_string_array']).is_a?(Array)
self.enum_form_string_array = value
end
end
if attributes.key?(:'enum_form_string')
self.enum_form_string = attributes[:'enum_form_string']
else
self.enum_form_string = '-efg'
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
enum_form_string_validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
return false unless enum_form_string_validator.valid?(@enum_form_string)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_form_string Object to be assigned
def enum_form_string=(enum_form_string)
validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
unless validator.valid?(enum_form_string)
fail ArgumentError, "invalid value for \"enum_form_string\", must be one of #{validator.allowable_values}."
end
@enum_form_string = enum_form_string
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
enum_form_string_array == o.enum_form_string_array &&
enum_form_string == o.enum_form_string
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[enum_form_string_array, enum_form_string].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,538 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject3
# None
attr_accessor :integer
# None
attr_accessor :int32
# None
attr_accessor :int64
# None
attr_accessor :number
# None
attr_accessor :float
# None
attr_accessor :double
# None
attr_accessor :string
# None
attr_accessor :pattern_without_delimiter
# None
attr_accessor :byte
# None
attr_accessor :binary
# None
attr_accessor :date
# None
attr_accessor :date_time
# None
attr_accessor :password
# None
attr_accessor :callback
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'integer' => :'integer',
:'int32' => :'int32',
:'int64' => :'int64',
:'number' => :'number',
:'float' => :'float',
:'double' => :'double',
:'string' => :'string',
:'pattern_without_delimiter' => :'pattern_without_delimiter',
:'byte' => :'byte',
:'binary' => :'binary',
:'date' => :'date',
:'date_time' => :'dateTime',
:'password' => :'password',
:'callback' => :'callback'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'integer' => :'Integer',
:'int32' => :'Integer',
:'int64' => :'Integer',
:'number' => :'Float',
:'float' => :'Float',
:'double' => :'Float',
:'string' => :'String',
:'pattern_without_delimiter' => :'String',
:'byte' => :'String',
:'binary' => :'File',
:'date' => :'Date',
:'date_time' => :'DateTime',
:'password' => :'String',
:'callback' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject3` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'integer')
self.integer = attributes[:'integer']
end
if attributes.key?(:'int32')
self.int32 = attributes[:'int32']
end
if attributes.key?(:'int64')
self.int64 = attributes[:'int64']
end
if attributes.key?(:'number')
self.number = attributes[:'number']
end
if attributes.key?(:'float')
self.float = attributes[:'float']
end
if attributes.key?(:'double')
self.double = attributes[:'double']
end
if attributes.key?(:'string')
self.string = attributes[:'string']
end
if attributes.key?(:'pattern_without_delimiter')
self.pattern_without_delimiter = attributes[:'pattern_without_delimiter']
end
if attributes.key?(:'byte')
self.byte = attributes[:'byte']
end
if attributes.key?(:'binary')
self.binary = attributes[:'binary']
end
if attributes.key?(:'date')
self.date = attributes[:'date']
end
if attributes.key?(:'date_time')
self.date_time = attributes[:'date_time']
end
if attributes.key?(:'password')
self.password = attributes[:'password']
end
if attributes.key?(:'callback')
self.callback = attributes[:'callback']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if !@integer.nil? && @integer > 100
invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.')
end
if !@integer.nil? && @integer < 10
invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.')
end
if !@int32.nil? && @int32 > 200
invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.')
end
if !@int32.nil? && @int32 < 20
invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.')
end
if @number.nil?
invalid_properties.push('invalid value for "number", number cannot be nil.')
end
if @number > 543.2
invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.')
end
if @number < 32.1
invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.')
end
if !@float.nil? && @float > 987.6
invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.')
end
if @double.nil?
invalid_properties.push('invalid value for "double", double cannot be nil.')
end
if @double > 123.4
invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.')
end
if @double < 67.8
invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
end
pattern = Regexp.new(/[a-z]/i)
if !@string.nil? && @string !~ pattern
invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.")
end
if @pattern_without_delimiter.nil?
invalid_properties.push('invalid value for "pattern_without_delimiter", pattern_without_delimiter cannot be nil.')
end
pattern = Regexp.new(/^[A-Z].*/)
if @pattern_without_delimiter !~ pattern
invalid_properties.push("invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}.")
end
if @byte.nil?
invalid_properties.push('invalid value for "byte", byte cannot be nil.')
end
if !@password.nil? && @password.to_s.length > 64
invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.')
end
if !@password.nil? && @password.to_s.length < 10
invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if !@integer.nil? && @integer > 100
return false if !@integer.nil? && @integer < 10
return false if !@int32.nil? && @int32 > 200
return false if !@int32.nil? && @int32 < 20
return false if @number.nil?
return false if @number > 543.2
return false if @number < 32.1
return false if !@float.nil? && @float > 987.6
return false if @double.nil?
return false if @double > 123.4
return false if @double < 67.8
return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
return false if @pattern_without_delimiter.nil?
return false if @pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/)
return false if @byte.nil?
return false if !@password.nil? && @password.to_s.length > 64
return false if !@password.nil? && @password.to_s.length < 10
true
end
# Custom attribute writer method with validation
# @param [Object] integer Value to be assigned
def integer=(integer)
if !integer.nil? && integer > 100
fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.'
end
if !integer.nil? && integer < 10
fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.'
end
@integer = integer
end
# Custom attribute writer method with validation
# @param [Object] int32 Value to be assigned
def int32=(int32)
if !int32.nil? && int32 > 200
fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.'
end
if !int32.nil? && int32 < 20
fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.'
end
@int32 = int32
end
# Custom attribute writer method with validation
# @param [Object] number Value to be assigned
def number=(number)
if number.nil?
fail ArgumentError, 'number cannot be nil'
end
if number > 543.2
fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.'
end
if number < 32.1
fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.'
end
@number = number
end
# Custom attribute writer method with validation
# @param [Object] float Value to be assigned
def float=(float)
if !float.nil? && float > 987.6
fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.'
end
@float = float
end
# Custom attribute writer method with validation
# @param [Object] double Value to be assigned
def double=(double)
if double.nil?
fail ArgumentError, 'double cannot be nil'
end
if double > 123.4
fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.'
end
if double < 67.8
fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.'
end
@double = double
end
# Custom attribute writer method with validation
# @param [Object] string Value to be assigned
def string=(string)
pattern = Regexp.new(/[a-z]/i)
if !string.nil? && string !~ pattern
fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}."
end
@string = string
end
# Custom attribute writer method with validation
# @param [Object] pattern_without_delimiter Value to be assigned
def pattern_without_delimiter=(pattern_without_delimiter)
if pattern_without_delimiter.nil?
fail ArgumentError, 'pattern_without_delimiter cannot be nil'
end
pattern = Regexp.new(/^[A-Z].*/)
if pattern_without_delimiter !~ pattern
fail ArgumentError, "invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}."
end
@pattern_without_delimiter = pattern_without_delimiter
end
# Custom attribute writer method with validation
# @param [Object] password Value to be assigned
def password=(password)
if !password.nil? && password.to_s.length > 64
fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.'
end
if !password.nil? && password.to_s.length < 10
fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.'
end
@password = password
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
integer == o.integer &&
int32 == o.int32 &&
int64 == o.int64 &&
number == o.number &&
float == o.float &&
double == o.double &&
string == o.string &&
pattern_without_delimiter == o.pattern_without_delimiter &&
byte == o.byte &&
binary == o.binary &&
date == o.date &&
date_time == o.date_time &&
password == o.password &&
callback == o.callback
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[integer, int32, int64, number, float, double, string, pattern_without_delimiter, byte, binary, date, date_time, password, callback].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,227 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject4
# field1
attr_accessor :param
# field2
attr_accessor :param2
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'param' => :'param',
:'param2' => :'param2'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'param' => :'String',
:'param2' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject4` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject4`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'param')
self.param = attributes[:'param']
end
if attributes.key?(:'param2')
self.param2 = attributes[:'param2']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @param.nil?
invalid_properties.push('invalid value for "param", param cannot be nil.')
end
if @param2.nil?
invalid_properties.push('invalid value for "param2", param2 cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @param.nil?
return false if @param2.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
param == o.param &&
param2 == o.param2
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[param, param2].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,222 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject5
# Additional data to pass to server
attr_accessor :additional_metadata
# file to upload
attr_accessor :required_file
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'additional_metadata' => :'additionalMetadata',
:'required_file' => :'requiredFile'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'additional_metadata' => :'String',
:'required_file' => :'File'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject5` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject5`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'additional_metadata')
self.additional_metadata = attributes[:'additional_metadata']
end
if attributes.key?(:'required_file')
self.required_file = attributes[:'required_file']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @required_file.nil?
invalid_properties.push('invalid value for "required_file", required_file cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @required_file.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
additional_metadata == o.additional_metadata &&
required_file == o.required_file
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[additional_metadata, required_file].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
Petstore.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@@ -1,47 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject1
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject1' do
before do
# run before each test
@instance = Petstore::InlineObject1.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject1' do
it 'should create an instance of InlineObject1' do
expect(@instance).to be_instance_of(Petstore::InlineObject1)
end
end
describe 'test attribute "additional_metadata"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "file"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -1,55 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject2
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject2' do
before do
# run before each test
@instance = Petstore::InlineObject2.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject2' do
it 'should create an instance of InlineObject2' do
expect(@instance).to be_instance_of(Petstore::InlineObject2)
end
end
describe 'test attribute "enum_form_string_array"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# validator = Petstore::EnumTest::EnumAttributeValidator.new('Array<String>', [">", "$"])
# validator.allowable_values.each do |value|
# expect { @instance.enum_form_string_array = value }.not_to raise_error
# end
end
end
describe 'test attribute "enum_form_string"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
# validator.allowable_values.each do |value|
# expect { @instance.enum_form_string = value }.not_to raise_error
# end
end
end
end

View File

@@ -1,119 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject3
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject3' do
before do
# run before each test
@instance = Petstore::InlineObject3.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject3' do
it 'should create an instance of InlineObject3' do
expect(@instance).to be_instance_of(Petstore::InlineObject3)
end
end
describe 'test attribute "integer"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "int32"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "int64"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "number"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "float"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "double"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "string"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "pattern_without_delimiter"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "byte"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "binary"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "date"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "date_time"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "password"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "callback"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -1,47 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject4
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject4' do
before do
# run before each test
@instance = Petstore::InlineObject4.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject4' do
it 'should create an instance of InlineObject4' do
expect(@instance).to be_instance_of(Petstore::InlineObject4)
end
end
describe 'test attribute "param"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "param2"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -1,47 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject5
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject5' do
before do
# run before each test
@instance = Petstore::InlineObject5.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject5' do
it 'should create an instance of InlineObject5' do
expect(@instance).to be_instance_of(Petstore::InlineObject5)
end
end
describe 'test attribute "additional_metadata"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "required_file"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -1,47 +0,0 @@
=begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject' do
before do
# run before each test
@instance = Petstore::InlineObject.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject' do
it 'should create an instance of InlineObject' do
expect(@instance).to be_instance_of(Petstore::InlineObject)
end
end
describe 'test attribute "name"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "status"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

Some files were not shown because too many files have changed in this diff Show More