forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/6.0.x'
This commit is contained in:
commit
0e1164ff6b
12
.github/.test/samples.json
vendored
12
.github/.test/samples.json
vendored
@ -145,12 +145,6 @@
|
||||
"Documentation: Cwiki"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-jaguar-petstore.sh",
|
||||
"matches": [
|
||||
"Client: Dart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "dart-dio-petstore.sh",
|
||||
"matches": [
|
||||
@ -223,12 +217,6 @@
|
||||
"Server: Scala"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "flash-petstore.sh",
|
||||
"matches": [
|
||||
"Client: Flash/ActionScript"
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": "go-gin-petstore-server.sh",
|
||||
"matches": [
|
||||
|
3
.github/auto-labeler.yml
vendored
3
.github/auto-labeler.yml
vendored
@ -62,9 +62,6 @@ labels:
|
||||
- '\s*?-[gl] erlang(-.*)?-client\s*?'
|
||||
- '\s*?\[erlang-proper\]\s*?'
|
||||
- '\s*?-[gl] erlang-proper\s*?'
|
||||
'Client: Flash/ActionScript':
|
||||
- '\s*?\[flash\]\s*?'
|
||||
- '\s*?-[gl] flash(?!-)\b'
|
||||
'Client: Go':
|
||||
- '\s*?\[go\]\s*?'
|
||||
- '\s*?-[gl] go(?!-)\b'
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -245,9 +245,6 @@ samples/server/petstore/erlang-server/rebar.lock
|
||||
**/dart*/**/pubspec.lock
|
||||
# Dart dio
|
||||
**/dart*/**/*.g.dart
|
||||
# Dart jaguar
|
||||
**/dart*/**/*.jser.dart
|
||||
**/dart*/**/*.jretro.dart
|
||||
|
||||
# JS
|
||||
samples/client/petstore/javascript-es6/package-lock.json
|
||||
|
@ -1,7 +0,0 @@
|
||||
generatorName: flash
|
||||
outputDir: samples/client/petstore/flash
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/flash
|
||||
additionalProperties:
|
||||
invokerPackage: org.openapitools
|
||||
packageName: org.openapitools
|
@ -24,13 +24,11 @@ The following generators are available:
|
||||
* [dart](generators/dart.md)
|
||||
* [dart-dio](generators/dart-dio.md)
|
||||
* [dart-dio-next (experimental)](generators/dart-dio-next.md)
|
||||
* [dart-jaguar (deprecated)](generators/dart-jaguar.md)
|
||||
* [eiffel](generators/eiffel.md)
|
||||
* [elixir](generators/elixir.md)
|
||||
* [elm](generators/elm.md)
|
||||
* [erlang-client](generators/erlang-client.md)
|
||||
* [erlang-proper](generators/erlang-proper.md)
|
||||
* [flash-deprecated (deprecated)](generators/flash-deprecated.md)
|
||||
* [go](generators/go.md)
|
||||
* [go-deprecated (deprecated)](generators/go-deprecated.md)
|
||||
* [groovy](generators/groovy.md)
|
||||
@ -67,7 +65,6 @@ The following generators are available:
|
||||
* [swift5](generators/swift5.md)
|
||||
* [typescript (experimental)](generators/typescript.md)
|
||||
* [typescript-angular](generators/typescript-angular.md)
|
||||
* [typescript-angularjs-deprecated (deprecated)](generators/typescript-angularjs-deprecated.md)
|
||||
* [typescript-aurelia](generators/typescript-aurelia.md)
|
||||
* [typescript-axios](generators/typescript-axios.md)
|
||||
* [typescript-fetch](generators/typescript-fetch.md)
|
||||
@ -113,14 +110,12 @@ The following generators are available:
|
||||
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
|
||||
* [jaxrs-spec](generators/jaxrs-spec.md)
|
||||
* [kotlin-server](generators/kotlin-server.md)
|
||||
* [kotlin-server-deprecated (deprecated)](generators/kotlin-server-deprecated.md)
|
||||
* [kotlin-spring](generators/kotlin-spring.md)
|
||||
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)
|
||||
* [nodejs-express-server (beta)](generators/nodejs-express-server.md)
|
||||
* [php-laravel](generators/php-laravel.md)
|
||||
* [php-lumen](generators/php-lumen.md)
|
||||
* [php-mezzio-ph](generators/php-mezzio-ph.md)
|
||||
* [php-silex-deprecated (deprecated)](generators/php-silex-deprecated.md)
|
||||
* [php-slim-deprecated (deprecated)](generators/php-slim-deprecated.md)
|
||||
* [php-slim4](generators/php-slim4.md)
|
||||
* [php-symfony](generators/php-symfony.md)
|
||||
|
@ -15,13 +15,11 @@ The following generators are available:
|
||||
* [csharp-netcore](csharp-netcore.md)
|
||||
* [dart](dart.md)
|
||||
* [dart-dio](dart-dio.md)
|
||||
* [dart-jaguar](dart-jaguar.md)
|
||||
* [eiffel](eiffel.md)
|
||||
* [elixir](elixir.md)
|
||||
* [elm](elm.md)
|
||||
* [erlang-client](erlang-client.md)
|
||||
* [erlang-proper](erlang-proper.md)
|
||||
* [flash](flash.md)
|
||||
* [go](go.md)
|
||||
* [go-experimental (experimental)](go-experimental.md)
|
||||
* [groovy](groovy.md)
|
||||
@ -92,7 +90,6 @@ The following generators are available:
|
||||
* [jaxrs-resteasy-eap](jaxrs-resteasy-eap.md)
|
||||
* [jaxrs-spec](jaxrs-spec.md)
|
||||
* [kotlin-server](kotlin-server.md)
|
||||
* [kotlin-server-deprecated](kotlin-server-deprecated.md)
|
||||
* [kotlin-spring](kotlin-spring.md)
|
||||
* [kotlin-vertx (beta)](kotlin-vertx.md)
|
||||
* [nodejs-express-server (beta)](nodejs-express-server.md)
|
||||
|
@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=5.4.0
|
||||
openApiGeneratorVersion=6.0.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
@ -64,7 +64,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public String defaultValue;
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isDecimal, isShort, isUnboundedInteger, isBoolean;
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean;
|
||||
private boolean additionalPropertiesIsAnyType;
|
||||
public List<CodegenProperty> vars = new ArrayList<>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<>(); // all properties (with parent's properties)
|
||||
@ -637,6 +637,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
|
||||
|
@ -623,6 +623,14 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
|
||||
|
@ -536,6 +536,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVendorExtensions() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
@ -371,6 +371,14 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return primitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.primitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
|
@ -99,6 +99,10 @@ public interface IJsonSchemaValidationProperties {
|
||||
|
||||
void setIsUnboundedInteger(boolean isUnboundedInteger);
|
||||
|
||||
boolean getIsPrimitiveType();
|
||||
|
||||
void setIsPrimitiveType(boolean isPrimitiveType);
|
||||
|
||||
CodegenProperty getAdditionalProperties();
|
||||
|
||||
void setAdditionalProperties(CodegenProperty additionalProperties);
|
||||
@ -264,4 +268,4 @@ public interface IJsonSchemaValidationProperties {
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,6 +281,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// {{sourceFolder}}
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
|
||||
// TODO: Move to its own option when a parameter for 'testFolder' is added.
|
||||
setTestFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, this.sourceFolder);
|
||||
}
|
||||
@ -1151,6 +1154,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
this.sourceFolder = sourceFolder;
|
||||
}
|
||||
|
||||
public void setTestFolder(String testFolder) {
|
||||
this.testFolder = testFolder;
|
||||
}
|
||||
|
||||
public String getInterfacePrefix() {
|
||||
return interfacePrefix;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
@ -112,12 +114,13 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
setReservedWordsLowerCase(reservedWordsList);
|
||||
|
||||
// These types return isPrimitive=true in templates
|
||||
languageSpecificPrimitives = new HashSet<>(5);
|
||||
languageSpecificPrimitives.add("String");
|
||||
languageSpecificPrimitives.add("bool");
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("num");
|
||||
languageSpecificPrimitives.add("double");
|
||||
languageSpecificPrimitives = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double"
|
||||
);
|
||||
|
||||
typeMapping = new HashMap<>();
|
||||
typeMapping.put("Array", "List");
|
||||
@ -148,17 +151,18 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
typeMapping.put("AnyType", "Object");
|
||||
|
||||
// Data types of the above values which are automatically imported
|
||||
defaultIncludes = new HashSet<>();
|
||||
defaultIncludes.add("String");
|
||||
defaultIncludes.add("bool");
|
||||
defaultIncludes.add("int");
|
||||
defaultIncludes.add("num");
|
||||
defaultIncludes.add("double");
|
||||
defaultIncludes.add("List");
|
||||
defaultIncludes.add("Set");
|
||||
defaultIncludes.add("Map");
|
||||
defaultIncludes.add("DateTime");
|
||||
defaultIncludes.add("Object");
|
||||
defaultIncludes = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"List",
|
||||
"Set",
|
||||
"Map",
|
||||
"DateTime",
|
||||
"Object"
|
||||
);
|
||||
|
||||
imports.put("String", "dart:core");
|
||||
imports.put("bool", "dart:core");
|
||||
|
@ -36,6 +36,7 @@ public class DartClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
public DartClientCodegen() {
|
||||
super();
|
||||
|
||||
final CliOption serializationLibrary = CliOption.newString(CodegenConstants.SERIALIZATION_LIBRARY,
|
||||
"Specify serialization library");
|
||||
serializationLibrary.setDefault(SERIALIZATION_LIBRARY_NATIVE);
|
||||
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TypeScriptAngularJsClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
|
||||
public TypeScriptAngularJsClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/typescript-angularjs";
|
||||
modelTemplateFiles.put("model.mustache", ".ts");
|
||||
apiTemplateFiles.put("api.mustache", ".ts");
|
||||
embeddedTemplateDir = templateDir = "typescript-angularjs";
|
||||
apiPackage = "api";
|
||||
modelPackage = "model";
|
||||
|
||||
removeOption(NPM_NAME);
|
||||
removeOption(NPM_VERSION);
|
||||
removeOption(SNAPSHOT);
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.DEPRECATED)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "typescript-angularjs-deprecated";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a TypeScript AngularJS client library. This generator has been deprecated and will be removed in the future release.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
|
||||
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
|
||||
supportingFiles.add(new SupportingFile("api.module.mustache", getIndexDirectory(), "api.module.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
if (isLanguagePrimitive(openAPIType) || isLanguageGenericType(openAPIType)) {
|
||||
return openAPIType;
|
||||
}
|
||||
return addModelPrefix(openAPIType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
return addModelPrefix(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
// parameter.dataType = addModelPrefix(parameter.dataType);
|
||||
}
|
||||
|
||||
private String getIndexDirectory() {
|
||||
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
|
||||
return indexPackage.replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
private String addModelPrefix(String openAPIType) {
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
} else {
|
||||
type = openAPIType;
|
||||
}
|
||||
|
||||
if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) {
|
||||
type = "models." + openAPIType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private boolean isLanguagePrimitive(String type) {
|
||||
return languageSpecificPrimitives.contains(type);
|
||||
}
|
||||
|
||||
private boolean isLanguageGenericType(String type) {
|
||||
for (String genericType : languageGenericTypes) {
|
||||
if (type.startsWith(genericType + "<")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ public class ServerConfiguration {
|
||||
if (variables != null && variables.containsKey(name)) {
|
||||
value = variables.get(name);
|
||||
if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
|
||||
throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
|
||||
throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + ".");
|
||||
}
|
||||
}
|
||||
url = url.replaceAll("\\{" + name + "\\}", value);
|
||||
|
@ -2,10 +2,13 @@
|
||||
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
/**
|
||||
* OAuth flows that are supported by this client
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public enum OAuthFlow {
|
||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
||||
implicit,
|
||||
password,
|
||||
application //called clientCredentials in OpenAPI 3.0
|
||||
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||
IMPLICIT,
|
||||
PASSWORD,
|
||||
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class ApiClient {
|
||||
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
auth = buildOauthRequestInterceptor(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||
auth = buildOauthRequestInterceptor(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||
{{/isOAuth}}
|
||||
} else {{/authMethods}}{
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
@ -179,9 +179,9 @@ public class ApiClient {
|
||||
{{#hasOAuthMethods}}
|
||||
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||
switch (flow) {
|
||||
case password:
|
||||
case PASSWORD:
|
||||
return new OauthPasswordGrant(tokenUrl, scopes);
|
||||
case application:
|
||||
case APPLICATION:
|
||||
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
||||
default:
|
||||
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
||||
|
@ -21,7 +21,7 @@ public class OauthClientCredentialsGrant extends OAuth {
|
||||
|
||||
@Override
|
||||
protected OAuthFlow getFlow() {
|
||||
return OAuthFlow.application;
|
||||
return OAuthFlow.APPLICATION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ public class OauthPasswordGrant extends OAuth {
|
||||
|
||||
@Override
|
||||
protected OAuthFlow getFlow() {
|
||||
return OAuthFlow.password;
|
||||
return OAuthFlow.PASSWORD;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,4 +45,4 @@ public class OauthPasswordGrant extends OAuth {
|
||||
.defaultScope(scopes)
|
||||
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class OAuth implements Authentication {
|
||||
|
||||
private String tokenUrl;
|
||||
private String absoluteTokenUrl;
|
||||
private OAuthFlow flow = OAuthFlow.application;
|
||||
private OAuthFlow flow = OAuthFlow.APPLICATION;
|
||||
private OAuth20Service service;
|
||||
private DefaultApi20 authApi;
|
||||
private String scope;
|
||||
@ -103,18 +103,18 @@ public class OAuth implements Authentication {
|
||||
}
|
||||
try {
|
||||
switch (flow) {
|
||||
case password:
|
||||
case PASSWORD:
|
||||
if (username != null && password != null) {
|
||||
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
||||
}
|
||||
break;
|
||||
case accessCode:
|
||||
case ACCESS_CODE:
|
||||
if (code != null) {
|
||||
accessToken = service.getAccessToken(code);
|
||||
code = null;
|
||||
}
|
||||
break;
|
||||
case application:
|
||||
case APPLICATION:
|
||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||
break;
|
||||
default:
|
||||
@ -159,14 +159,14 @@ public class OAuth implements Authentication {
|
||||
}
|
||||
|
||||
public OAuth usePasswordFlow(String username, String password) {
|
||||
this.flow = OAuthFlow.password;
|
||||
this.flow = OAuthFlow.PASSWORD;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OAuth useAuthorizationCodeFlow(String code) {
|
||||
this.flow = OAuthFlow.accessCode;
|
||||
this.flow = OAuthFlow.ACCESS_CODE;
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
@ -2,6 +2,12 @@
|
||||
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
/**
|
||||
* OAuth flows that are supported by this client
|
||||
*/
|
||||
public enum OAuthFlow {
|
||||
accessCode, implicit, password, application
|
||||
ACCESS_CODE,
|
||||
IMPLICIT,
|
||||
PASSWORD,
|
||||
APPLICATION
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class ApiClient {
|
||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||
}
|
||||
}
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{flow}}, clientSecret, parameters);
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, clientSecret, parameters);
|
||||
authentications.put(
|
||||
"{{name}}",
|
||||
retryingOAuth
|
||||
|
@ -79,16 +79,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
*/
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case ACCESS_CODE:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case implicit:
|
||||
case IMPLICIT:
|
||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||
break;
|
||||
case password:
|
||||
case PASSWORD:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
case APPLICATION:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
|
@ -197,7 +197,7 @@ public class ApiClient {
|
||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||
}
|
||||
}
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{flow}}, clientSecret, parameters);
|
||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, clientSecret, parameters);
|
||||
authentications.put(
|
||||
"{{name}}",
|
||||
retryingOAuth
|
||||
|
@ -65,16 +65,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case ACCESS_CODE:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case implicit:
|
||||
case IMPLICIT:
|
||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||
break;
|
||||
case password:
|
||||
case PASSWORD:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
case APPLICATION:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
||||
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case implicit:
|
||||
case ACCESS_CODE:
|
||||
case IMPLICIT:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case password:
|
||||
case PASSWORD:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
case APPLICATION:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
|
@ -82,7 +82,7 @@ public class ApiClient {
|
||||
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||
auth = new OAuth(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||
{{/isOAuth}}
|
||||
} else {{/authMethods}}{
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
||||
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case implicit:
|
||||
case ACCESS_CODE:
|
||||
case IMPLICIT:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case password:
|
||||
case PASSWORD:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
case APPLICATION:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
|
@ -27,14 +27,12 @@ org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
|
||||
org.openapitools.codegen.languages.DartClientCodegen
|
||||
org.openapitools.codegen.languages.DartDioClientCodegen
|
||||
org.openapitools.codegen.languages.DartDioNextClientCodegen
|
||||
org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
org.openapitools.codegen.languages.EiffelClientCodegen
|
||||
org.openapitools.codegen.languages.ElixirClientCodegen
|
||||
org.openapitools.codegen.languages.ElmClientCodegen
|
||||
org.openapitools.codegen.languages.ErlangClientCodegen
|
||||
org.openapitools.codegen.languages.ErlangProperCodegen
|
||||
org.openapitools.codegen.languages.ErlangServerCodegen
|
||||
org.openapitools.codegen.languages.FlashClientCodegen
|
||||
org.openapitools.codegen.languages.FsharpFunctionsServerCodegen
|
||||
org.openapitools.codegen.languages.FsharpGiraffeServerCodegen
|
||||
org.openapitools.codegen.languages.GoClientCodegen
|
||||
@ -47,7 +45,6 @@ org.openapitools.codegen.languages.GraphQLNodeJSExpressServerCodegen
|
||||
org.openapitools.codegen.languages.GroovyClientCodegen
|
||||
org.openapitools.codegen.languages.KotlinClientCodegen
|
||||
org.openapitools.codegen.languages.KotlinServerCodegen
|
||||
org.openapitools.codegen.languages.KotlinServerDeprecatedCodegen
|
||||
org.openapitools.codegen.languages.KotlinSpringServerCodegen
|
||||
org.openapitools.codegen.languages.KotlinVertxServerCodegen
|
||||
org.openapitools.codegen.languages.KtormSchemaCodegen
|
||||
@ -95,7 +92,6 @@ org.openapitools.codegen.languages.PhpLaravelServerCodegen
|
||||
org.openapitools.codegen.languages.PhpLumenServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSlimServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSlim4ServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSilexServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSymfonyServerCodegen
|
||||
org.openapitools.codegen.languages.PhpMezzioPathHandlerServerCodegen
|
||||
org.openapitools.codegen.languages.PhpDataTransferClientCodegen
|
||||
@ -131,7 +127,6 @@ org.openapitools.codegen.languages.StaticHtml2Generator
|
||||
org.openapitools.codegen.languages.Swift5ClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAngularClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAngularJsClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptFetchClientCodegen
|
||||
|
@ -1,141 +0,0 @@
|
||||
# {{pubName}}
|
||||
{{#appDescriptionWithNewLines}}
|
||||
{{{.}}}
|
||||
{{/appDescriptionWithNewLines}}
|
||||
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
{{#artifactVersion}}
|
||||
- Package version: {{.}}
|
||||
{{/artifactVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2 or later OR Flutter 0.7.0 or later.
|
||||
|
||||
Once your code is generated, you need to run the build_runner command to let Jaguar implement your API:
|
||||
|
||||
```sh
|
||||
flutter packages pub run build_runner build
|
||||
or
|
||||
pub run build_runner build
|
||||
```
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Github
|
||||
If this Dart package is published to Github, please include the following in pubspec.yaml
|
||||
```
|
||||
name: {{pubName}}
|
||||
version: {{pubVersion}}
|
||||
description: {{pubDescription}}
|
||||
dependencies:
|
||||
{{pubName}}:
|
||||
git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
|
||||
version: 'any'
|
||||
```
|
||||
|
||||
### Local
|
||||
To use the package in your local drive, please include the following in pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
{{pubName}}:
|
||||
path: /path/to/{{pubName}}
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
TODO
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
// TODO Configure HTTP basic authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME';
|
||||
//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
// TODO Configure API key authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer";
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
// TODO Configure OAuth2 access token for authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
final jaguarApiGen = {{clientName}}();
|
||||
var api_instance = jaguarApiGen.get{{classname}}();
|
||||
{{#allParams}}
|
||||
var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
try {
|
||||
{{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{#returnType}}
|
||||
print(result);
|
||||
{{/returnType}}
|
||||
} catch (e) {
|
||||
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
|
||||
}
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
{{^authMethods}} All endpoints do not require authorization.
|
||||
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||
{{#authMethods}}## {{{name}}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
- **API key parameter name**: {{{keyParamName}}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
|
||||
{{/-last}}{{/apis}}{{/apiInfo}}
|
@ -1 +0,0 @@
|
||||
analyzer:
|
@ -1,78 +0,0 @@
|
||||
import 'package:jaguar_retrofit/annotations/annotations.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
import 'dart:async';
|
||||
|
||||
{{#operations}}
|
||||
{{#modelImports}}import 'package:{{pubName}}/model/{{.}}{{#protoFormat}}.pb{{/protoFormat}}.dart';
|
||||
{{/modelImports}}
|
||||
{{#fullImports}}import '{{.}}';
|
||||
{{/fullImports}}
|
||||
|
||||
part '{{classFilename}}.jretro.dart';
|
||||
|
||||
@GenApiClient()
|
||||
class {{classname}} extends ApiClient with _${{classname}}Client {
|
||||
final Route base;
|
||||
final Map<String, CodecRepo> converters;
|
||||
final Duration timeout;
|
||||
|
||||
{{classname}}({this.base, this.converters, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
{{#operation}}
|
||||
/// {{summary}}
|
||||
///
|
||||
/// {{notes}}
|
||||
@{{httpMethod}}Req(path: "{{path}}"{{#hasAuthMethods}}, metadata: {"auth": [{{#authMethods}} {"type": "{{type}}", "name": "{{name}}"{{#isApiKey}}, "keyName": "{{keyParamName}}", "where": "{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}"{{/isApiKey}} }{{^-last}}, {{/-last}}{{/authMethods}}]}{{/hasAuthMethods}})
|
||||
Future<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{nickname}}(
|
||||
{{#pathParams}}
|
||||
@PathParam("{{baseName}}") {{dataType}} {{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/pathParams}}
|
||||
{{#headerParams}}
|
||||
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
||||
@Header("{{baseName}}") {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
|
||||
@QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/queryParams}}
|
||||
{{#vendorExtensions}}
|
||||
{{#formParams}}
|
||||
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
||||
{{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsFormField() {{/x-is-form}}{{#x-is-multipart}}@AsMultipartField() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
|
||||
{{^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}}
|
||||
{{/bodyParam}}
|
||||
{{/vendorExtensions}}
|
||||
) {
|
||||
return super.{{nickname}}(
|
||||
{{#pathParams}}
|
||||
{{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/pathParams}}
|
||||
{{#headerParams}}
|
||||
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
||||
{{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
|
||||
{{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/queryParams}}
|
||||
|
||||
{{#formParams}}
|
||||
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
||||
{{paramName}}{{^-last}}, {{/-last}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
|
||||
{{paramName}}
|
||||
{{/bodyParam}}
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
|
||||
}
|
||||
{{/operations}}
|
@ -1,86 +0,0 @@
|
||||
# {{pubName}}.api.{{classname}}{{#description}}
|
||||
{{.}}{{/description}}
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
# **{{{operationId}}}**
|
||||
> {{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{.}}}{{/notes}}
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
// TODO Configure HTTP basic authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME';
|
||||
//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
// TODO Configure API key authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer";
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
// TODO Configure OAuth2 access token for authorization: {{{name}}}
|
||||
//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
var api_instance = new {{classname}}();
|
||||
{{#allParams}}
|
||||
var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
try {
|
||||
{{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{#returnType}}
|
||||
print(result);
|
||||
{{/returnType}}
|
||||
} catch (e) {
|
||||
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -1,28 +0,0 @@
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
{{#operations}}
|
||||
|
||||
/// tests for {{classname}}
|
||||
void main() {
|
||||
var instance = new {{classname}}();
|
||||
|
||||
group('tests for {{classname}}', () {
|
||||
{{#operation}}
|
||||
{{#summary}}
|
||||
// {{{.}}}
|
||||
//
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
// {{{.}}}
|
||||
//
|
||||
{{/notes}}
|
||||
//{{#returnType}}Future<{{{.}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
|
||||
test('test {{operationId}}', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
{{/operation}}
|
||||
});
|
||||
}
|
||||
{{/operations}}
|
@ -1,100 +0,0 @@
|
||||
library {{pubName}}.api;
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
{{#protoFormat}}
|
||||
import 'package:jaguar_serializer_protobuf/proto_repo.dart';
|
||||
{{/protoFormat}}
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:{{pubName}}/auth/api_key_auth.dart';
|
||||
import 'package:{{pubName}}/auth/basic_auth.dart';
|
||||
import 'package:{{pubName}}/auth/oauth.dart';
|
||||
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
|
||||
{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/api/{{classFilename}}.dart';
|
||||
{{/apis}}{{/apiInfo}}
|
||||
{{#models}}{{#model}}import 'package:{{pubName}}/model/{{classFilename}}{{#protoFormat}}.pb{{/protoFormat}}.dart';
|
||||
{{/model}}{{/models}}
|
||||
|
||||
|
||||
{{#jsonFormat}}
|
||||
final _jsonJaguarRepo = JsonRepo()
|
||||
{{#models}}{{#model}}{{^isEnum}}..add({{classname}}Serializer()){{/isEnum}}
|
||||
{{/model}}{{/models}};
|
||||
final Map<String, CodecRepo> defaultConverters = {
|
||||
MimeTypes.json: _jsonJaguarRepo,
|
||||
};
|
||||
{{/jsonFormat}}
|
||||
|
||||
{{#protoFormat}}
|
||||
final _protoJaguarRepo = ProtoCodecRepo()
|
||||
{{#models}}{{#model}}..add((data) => {{classname}}.fromBuffer(List<int>.from(data)))
|
||||
{{/model}}{{/models}};
|
||||
final _jsonJaguarRepo = ProtoCodecRepo(isJsonFormatEnabled: true)
|
||||
{{#models}}{{#model}}..add((data) => {{classname}}.fromBuffer(List<int>.from(data)))
|
||||
{{/model}}{{/models}};
|
||||
final Map<String, CodecRepo> defaultConverters = {
|
||||
MimeTypes.json: _jsonJaguarRepo,
|
||||
MimeTypes.binary: _protoJaguarRepo,
|
||||
};
|
||||
{{/protoFormat}}
|
||||
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class {{clientName}} {
|
||||
List<Interceptor> interceptors;
|
||||
String basePath = "{{basePath}}";
|
||||
Route _baseRoute;
|
||||
final Duration timeout;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
{{clientName}}({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? http.Client());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
}
|
||||
else if(overrideInterceptors){
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
else {
|
||||
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
||||
}
|
||||
|
||||
this.interceptors.forEach((interceptor) {
|
||||
_baseRoute.before(interceptor.before);
|
||||
_baseRoute.after(interceptor.after);
|
||||
});
|
||||
}
|
||||
|
||||
void setOAuthToken(String name, String token) {
|
||||
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
|
||||
}
|
||||
|
||||
void setBasicAuth(String name, String username, String password) {
|
||||
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
|
||||
}
|
||||
|
||||
void setApiKey(String name, String apiKey) {
|
||||
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
|
||||
}
|
||||
|
||||
{{#apiInfo}}{{#apis}}
|
||||
/**
|
||||
* Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
{{classname}} get{{classname}}({Route base, Map<String, CodecRepo> converters}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if(converters == null) {
|
||||
converters = defaultConverters;
|
||||
}
|
||||
return {{classname}}(base: base, converters: converters, timeout: timeout);
|
||||
}
|
||||
|
||||
{{/apis}}{{/apiInfo}}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
|
||||
class ApiKeyAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> apiKeys = {};
|
||||
|
||||
@override
|
||||
FutureOr<void> before(RouteBase route) {
|
||||
final authInfo = getAuthInfo(route, "apiKey");
|
||||
for (var info in authInfo) {
|
||||
final authName = info["name"];
|
||||
final authKeyName = info["keyName"];
|
||||
final authWhere = info["where"];
|
||||
final apiKey = apiKeys[authName];
|
||||
if(apiKey != null) {
|
||||
if(authWhere == 'query'){
|
||||
route.query(authKeyName, apiKey);
|
||||
}
|
||||
else {
|
||||
route.header(authKeyName, apiKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.before(route);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr after(StringResponse response) {
|
||||
return Future.value(response);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
|
||||
abstract class AuthInterceptor extends Interceptor {
|
||||
/*
|
||||
* Get auth information on given route for the given type
|
||||
* Can return null if type is not present on auth data or if route doesn't need authentication
|
||||
*/
|
||||
List<Map<String, dynamic>> getAuthInfo(RouteBase route, String type) {
|
||||
if (route.metadataMap.containsKey("auth")) {
|
||||
final auth = route.metadataMap["auth"];
|
||||
List<Map<String, dynamic>> results = [];
|
||||
for (var info in auth) {
|
||||
if(info["type"] == type) {
|
||||
results.add(info);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
|
||||
class BasicAuthInfo {
|
||||
final String username;
|
||||
final String password;
|
||||
|
||||
const BasicAuthInfo(this.username, this.password);
|
||||
|
||||
}
|
||||
|
||||
class BasicAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, BasicAuthInfo> authInfo = {};
|
||||
|
||||
@override
|
||||
FutureOr<void> before(RouteBase route) {
|
||||
final metadataAuthInfo = getAuthInfo(route, "basic");
|
||||
for (var info in metadataAuthInfo) {
|
||||
final authName = info["name"];
|
||||
final basicAuthInfo = authInfo[authName];
|
||||
if(basicAuthInfo != null) {
|
||||
route.basicAuth(basicAuthInfo.username, basicAuthInfo.password);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.before(route);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr after(StringResponse response) {
|
||||
return Future.value(response);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
|
||||
class OAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> tokens = {};
|
||||
|
||||
@override
|
||||
FutureOr<void> before(RouteBase route) {
|
||||
final authInfo = getAuthInfo(route, "oauth");
|
||||
for (var info in authInfo) {
|
||||
final token = tokens[info["name"]];
|
||||
if(token != null) {
|
||||
route.header("Authorization", "Bearer ${token}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.before(route);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr after(StringResponse response) {
|
||||
return Future.value(response);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
{{#protoFormat}}
|
||||
message {{classname}} {
|
||||
{{#vars}}
|
||||
{{#vendorExtensions}}{{{x-proto-type}}} {{name}} = {{x-index}}{{/vendorExtensions}};
|
||||
{{/vars}}
|
||||
}
|
||||
{{/protoFormat}}
|
||||
{{#jsonFormat}}
|
||||
part '{{classFilename}}.jser.dart';
|
||||
|
||||
class {{classname}} {
|
||||
{{#vars}}{{#description}} /* {{{.}}} */{{/description}}
|
||||
@Alias('{{{baseName}}}', isNullable:{{#isNullable}} true{{/isNullable}}{{^isNullable}} false{{/isNullable}},{{#allowableValues}}
|
||||
{{^enumVars.empty}}{{^isString}}{{! isString because inline enums are not handled for now }}
|
||||
processor: const {{{datatype}}}FieldProcessor(),
|
||||
{{/isString}}{{/enumVars.empty}}
|
||||
{{/allowableValues}}
|
||||
)
|
||||
final {{{datatype}}} {{name}};
|
||||
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}}{{/vars}}
|
||||
|
||||
{{classname}}(
|
||||
{{#vars}}{{^defaultValue}}{{#required}} this.{{name}}, {{/required}}{{/defaultValue}}{{/vars}}
|
||||
|
||||
{{#vendorExtensions}}{{#x-has-vars}}{
|
||||
{{#vars}}{{^required}} this.{{name}}{{#defaultValue}} = {{{defaultValue}}}{{^-last}}, {{/-last}} {{/defaultValue}}{{/required}}
|
||||
{{#required}} {{#defaultValue}}this.{{name}} = {{{defaultValue}}}{{^-last}}, {{/-last}} {{/defaultValue}}{{/required}}{{/vars}}
|
||||
}{{/x-has-vars}}{{/vendorExtensions}}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '{{classname}}[{{#vars}}{{name}}=${{name}}, {{/vars}}]';
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer(nullableFields: {{nullableFields}})
|
||||
class {{classname}}Serializer extends Serializer<{{classname}}> with _${{classname}}Serializer {
|
||||
|
||||
}
|
||||
{{/jsonFormat}}
|
@ -1,37 +0,0 @@
|
||||
|
||||
{{#jsonFormat}}
|
||||
class {{classname}} {
|
||||
/// The underlying value of this enum member.
|
||||
final {{dataType}} value;
|
||||
|
||||
const {{classname}}._internal(this.value);
|
||||
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#description}}
|
||||
/// {{.}}
|
||||
{{/description}}
|
||||
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
|
||||
class {{classname}}FieldProcessor implements FieldProcessor<{{classname}}, {{dataType}}> {
|
||||
const {{classname}}FieldProcessor();
|
||||
|
||||
{{classname}} deserialize({{dataType}} data) {
|
||||
switch (data) {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{{value}}}: return {{classname}}.{{{name}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default: throw('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
|
||||
{{dataType}} serialize({{classname}} item) {
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
{{/jsonFormat}}
|
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
@ -1,27 +0,0 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
|
||||
# Files created by dart2js
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# rules if you intend to use dart2js directly
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
*.dart.js
|
||||
*.part.js
|
||||
*.js.deps
|
||||
*.js.map
|
||||
*.info.json
|
||||
|
||||
# Directory created by dartdoc
|
||||
doc/api/
|
||||
|
||||
# Don't commit pubspec lock file
|
||||
# (Library packages only! Remove pattern if developing an application package)
|
||||
pubspec.lock
|
@ -1,12 +0,0 @@
|
||||
{{#jsonFormat}}import 'package:jaguar_serializer/jaguar_serializer.dart';{{/jsonFormat}}
|
||||
{{#protoFormat}}syntax = "proto3";{{/protoFormat}}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#imports}}
|
||||
{{#jsonFormat}}import 'package:{{pubName}}/model/{{.}}.dart';{{/jsonFormat}}
|
||||
{{#protoFormat}}import "{{.}}.proto";{{/protoFormat}}
|
||||
{{/imports}}
|
||||
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -1,26 +0,0 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for {{classname}}
|
||||
void main() {
|
||||
var instance = new {{classname}}();
|
||||
|
||||
group('test {{classname}}', () {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
// {{{.}}}
|
||||
{{/description}}
|
||||
// {{{dataType}}} {{name}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
|
||||
test('to test the property `{{name}}`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
{{/vars}}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -1,16 +0,0 @@
|
||||
{{#models}}{{#model}}# {{pubName}}.model.{{classname}}
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}{{/models}}
|
@ -1,20 +0,0 @@
|
||||
name: {{pubName}}
|
||||
version: {{pubVersion}}
|
||||
description: {{pubDescription}}
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: ^2.8.8
|
||||
{{#jsonFormat}}
|
||||
jaguar_serializer: ^2.2.12
|
||||
{{/jsonFormat}}
|
||||
{{#protoFormat}}
|
||||
jaguar_serializer_protobuf: ^2.2.2
|
||||
jaguar_mimetype: ^1.0.1
|
||||
{{/protoFormat}}
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: ^2.8.10
|
||||
{{#jsonFormat}}
|
||||
jaguar_serializer_cli: ^2.2.8
|
||||
{{/jsonFormat}}
|
||||
build_runner: ^1.6.5
|
@ -1,11 +0,0 @@
|
||||
# https://docs.travis-ci.com/user/languages/dart/
|
||||
#
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "1.24.3"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
script:
|
||||
- pub run test
|
@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.0 or later
|
||||
Dart 2.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
{{#operations}}
|
||||
|
||||
class {{{classname}}} {
|
||||
{{{classname}}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
{{{classname}}}([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
{{#operation}}
|
||||
@ -49,24 +49,13 @@ class {{{classname}}} {
|
||||
///
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
{{#hasParams}}
|
||||
// Verify required params are set.
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
if ({{{paramName}}} == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: {{{paramName}}}');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{/hasParams}}
|
||||
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'{{{path}}}'{{#pathParams}}
|
||||
.replaceAll({{=<% %>=}}'{<% baseName %>}'<%={{ }}=%>, {{{paramName}}}{{^isString}}.toString(){{/isString}}){{/pathParams}};
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||
Object? postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -77,7 +66,7 @@ class {{{classname}}} {
|
||||
{{^required}}
|
||||
if ({{{paramName}}} != null) {
|
||||
{{/required}}
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('{{{collectionFormat}}}', '{{{baseName}}}', {{{paramName}}}));
|
||||
queryParams.addAll(_queryParams('{{{collectionFormat}}}', '{{{baseName}}}', {{{paramName}}}));
|
||||
{{^required}}
|
||||
}
|
||||
{{/required}}
|
||||
@ -139,7 +128,7 @@ class {{{classname}}} {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -174,7 +163,7 @@ class {{{classname}}} {
|
||||
///
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
Future<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
Future<{{#returnType}}{{{.}}}?{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -183,13 +172,13 @@ class {{{classname}}} {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
{{#native_serialization}}
|
||||
{{#isArray}}
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, '{{{returnType}}}') as List)
|
||||
.cast<{{{returnBaseType}}}>()
|
||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(){{/uniqueItems}};
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
@ -199,7 +188,7 @@ class {{{classname}}} {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}};
|
||||
{{/isMap}}{{/isArray}}{{/native_serialization}}
|
||||
}
|
||||
return Future<{{{returnType}}}>.value();
|
||||
return null;
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
|
@ -33,12 +33,7 @@ class ApiClient {
|
||||
Client get client => _client;
|
||||
|
||||
/// Requests to use a new HTTP [Client] in this class.
|
||||
///
|
||||
/// If the [newClient] is null, an [ArgumentError] is thrown.
|
||||
set client(Client newClient) {
|
||||
if (newClient == null) {
|
||||
throw ArgumentError('New client instance cannot be null.');
|
||||
}
|
||||
_client = newClient;
|
||||
}
|
||||
|
||||
@ -55,7 +50,7 @@ class ApiClient {
|
||||
/// or deleted.
|
||||
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
T? getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
}
|
||||
@ -66,35 +61,28 @@ class ApiClient {
|
||||
String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Object body,
|
||||
Object? body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
String nullableContentType,
|
||||
String? contentType,
|
||||
List<String> authNames,
|
||||
) async {
|
||||
_updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
|
||||
final urlEncodedQueryParams = queryParams
|
||||
.where((param) => param.value != null)
|
||||
.map((param) => '$param');
|
||||
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty
|
||||
? '?${urlEncodedQueryParams.join('&')}'
|
||||
: '';
|
||||
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
if (nullableContentType != null) {
|
||||
headerParams['Content-Type'] = nullableContentType;
|
||||
if (contentType != null) {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
}
|
||||
|
||||
final urlEncodedQueryParams = queryParams.map((param) => '$param');
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty ? '?${urlEncodedQueryParams.join('&')}' : '';
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
try {
|
||||
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||
if (
|
||||
body is MultipartFile && (nullableContentType == null ||
|
||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
body is MultipartFile && (contentType == null ||
|
||||
!contentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
) {
|
||||
final request = StreamedRequest(method, uri);
|
||||
request.headers.addAll(headerParams);
|
||||
@ -120,7 +108,7 @@ class ApiClient {
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||
final msgBody = contentType == 'application/x-www-form-urlencoded'
|
||||
? formParams
|
||||
: await serializeAsync(body);
|
||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||
@ -133,43 +121,71 @@ class ApiClient {
|
||||
case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,);
|
||||
case 'GET': return await _client.get(uri, headers: nullableHeaderParams,);
|
||||
}
|
||||
} on SocketException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Socket operation failed: $method $path', e, trace,);
|
||||
} on TlsException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'TLS/SSL communication failed: $method $path', e, trace,);
|
||||
} on IOException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'I/O operation failed: $method $path', e, trace,);
|
||||
} on ClientException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'HTTP connection failed: $method $path', e, trace,);
|
||||
} on Exception catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Exception occurred: $method $path', e, trace,);
|
||||
} on SocketException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Socket operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on TlsException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'TLS/SSL communication failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on IOException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'I/O operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on ClientException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'HTTP connection failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on Exception catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Exception occurred: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
}
|
||||
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
throw ApiException(
|
||||
HttpStatus.badRequest,
|
||||
'Invalid HTTP operation: $method $path',
|
||||
);
|
||||
}
|
||||
{{#native_serialization}}
|
||||
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) async =>
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
deserialize(json, targetType, growable: growable);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||
dynamic deserialize(String json, String targetType, {bool growable = false,}) {
|
||||
// Remove all spaces. Necessary for regular expressions as well.
|
||||
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||
|
||||
// If the expected target type is String, nothing to do...
|
||||
return targetType == 'String'
|
||||
? json
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable);
|
||||
}
|
||||
{{/native_serialization}}
|
||||
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||
Future<String> serializeAsync(Object? value) async => serialize(value);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||
String serialize(Object? value) => value == null ? '' : json.encode(value);
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
@ -188,7 +204,7 @@ class ApiClient {
|
||||
}
|
||||
|
||||
{{#native_serialization}}
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
@ -215,24 +231,21 @@ class ApiClient {
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
dynamic match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toList(growable: growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
|
||||
return Map<String, dynamic>.fromIterables(
|
||||
value.keys.cast<String>(),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable)),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -248,9 +261,9 @@ class ApiClient {
|
||||
/// Primarily intended for use in an isolate.
|
||||
class DeserializationMessage {
|
||||
const DeserializationMessage({
|
||||
@required this.json,
|
||||
@required this.targetType,
|
||||
this.growable,
|
||||
required this.json,
|
||||
required this.targetType,
|
||||
this.growable = false,
|
||||
});
|
||||
|
||||
/// The JSON value to deserialize.
|
||||
@ -274,10 +287,10 @@ Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||
: ApiClient._deserialize(
|
||||
jsonDecode(message.json),
|
||||
targetType,
|
||||
growable: message.growable == true,
|
||||
growable: message.growable,
|
||||
);
|
||||
}
|
||||
{{/native_serialization}}
|
||||
|
||||
/// Primarily intended for use in an isolate.
|
||||
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||
Future<String> serializeAsync(Object? value) async => value == null ? '' : json.encode(value);
|
||||
|
@ -6,9 +6,9 @@ class ApiException implements Exception {
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
int code = 0;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
String? message;
|
||||
Exception? innerException;
|
||||
StackTrace? stackTrace;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
@ -11,32 +11,27 @@ class QueryParam {
|
||||
}
|
||||
|
||||
// Ported from the Java version.
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat,
|
||||
String name,
|
||||
dynamic value,
|
||||
) {
|
||||
Iterable<QueryParam> _queryParams(String collectionFormat, String name, dynamic value,) {
|
||||
// Assertions to run in debug mode only.
|
||||
assert(name.isNotEmpty, 'Parameter cannot be an empty string.');
|
||||
|
||||
final params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name != null && name.isNotEmpty && value != null) {
|
||||
if (value is List) {
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||
}
|
||||
|
||||
// Default collection format is 'csv'.
|
||||
if (collectionFormat == null || collectionFormat.isEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
collectionFormat = 'csv';
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter)),);
|
||||
} else {
|
||||
params.add(QueryParam(name, parameterToString(value),));
|
||||
if (value is List) {
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||
}
|
||||
|
||||
// Default collection format is 'csv'.
|
||||
if (collectionFormat.isEmpty) {
|
||||
collectionFormat = 'csv'; // ignore: parameter_assignments
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter),));
|
||||
} else if (value != null) {
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
}
|
||||
|
||||
return params;
|
||||
@ -67,27 +62,27 @@ String parameterToString(dynamic value) {
|
||||
Future<String> _decodeBodyBytes(Response response) async {
|
||||
final contentType = response.headers['content-type'];
|
||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||
? response.bodyBytes.isEmpty ? '' : utf8.decode(response.bodyBytes)
|
||||
: response.body;
|
||||
}
|
||||
|
||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||
T mapValueOfType<T>(dynamic map, String key) {
|
||||
T? mapValueOfType<T>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is T ? value : null;
|
||||
}
|
||||
|
||||
/// Returns a valid Map<K, V> found at the specified Map [key], null otherwise.
|
||||
Map<K, V> mapCastOfType<K, V>(dynamic map, String key) {
|
||||
Map<K, V>? mapCastOfType<K, V>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is Map ? value.cast<K, V>() : null;
|
||||
}
|
||||
|
||||
/// Returns a valid [DateTime] found at the specified Map [key], null otherwise.
|
||||
DateTime mapDateTime(dynamic map, String key, [String pattern]) {
|
||||
DateTime? mapDateTime(dynamic map, String key, [String? pattern]) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
if (value != null) {
|
||||
int millis;
|
||||
int? millis;
|
||||
if (value is int) {
|
||||
millis = value;
|
||||
} else if (value is String) {
|
||||
|
@ -6,7 +6,7 @@ import 'package:test/test.dart';
|
||||
|
||||
/// tests for {{{classname}}}
|
||||
void main() {
|
||||
final instance = {{{classname}}}();
|
||||
// final instance = {{{classname}}}();
|
||||
|
||||
group('tests for {{{classname}}}', () {
|
||||
{{#operation}}
|
||||
|
@ -6,23 +6,25 @@ class ApiKeyAuth implements Authentication {
|
||||
final String location;
|
||||
final String paramName;
|
||||
|
||||
String apiKeyPrefix;
|
||||
String apiKey;
|
||||
String apiKeyPrefix = '';
|
||||
String apiKey = '';
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
} else if (location == 'cookie' && value != null) {
|
||||
headerParams.update(
|
||||
'Cookie',
|
||||
(existingCookie) => '$existingCookie; $paramName=$value',
|
||||
ifAbsent: () => '$paramName=$value',
|
||||
);
|
||||
if (paramValue.isNotEmpty) {
|
||||
if (location == 'query') {
|
||||
queryParams.add(QueryParam(paramName, paramValue));
|
||||
} else if (location == 'header') {
|
||||
headerParams[paramName] = paramValue;
|
||||
} else if (location == 'cookie') {
|
||||
headerParams.update(
|
||||
'Cookie',
|
||||
(existingCookie) => '$existingCookie; $paramName=$paramValue',
|
||||
ifAbsent: () => '$paramName=$paramValue',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,12 +1,16 @@
|
||||
{{>header}}
|
||||
{{>part_of}}
|
||||
class HttpBasicAuth implements Authentication {
|
||||
HttpBasicAuth({this.username = '', this.password = ''});
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final credentials = '${username ?? ''}:${password ?? ''}';
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
if (username.isNotEmpty && password.isNotEmpty) {
|
||||
final credentials = '$username:$password';
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,29 @@ class HttpBearerAuth implements Authentication {
|
||||
|
||||
set accessToken(dynamic accessToken) {
|
||||
if (accessToken is! String && accessToken is! HttpBearerAuthProvider) {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
throw ArgumentError('accessToken value must be either a String or a String Function().');
|
||||
}
|
||||
_accessToken = accessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (_accessToken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String accessToken;
|
||||
|
||||
if (_accessToken is String) {
|
||||
headerParams['Authorization'] = 'Bearer $_accessToken';
|
||||
accessToken = _accessToken;
|
||||
} else if (_accessToken is HttpBearerAuthProvider) {
|
||||
headerParams['Authorization'] = 'Bearer ${_accessToken()}';
|
||||
accessToken = _accessToken!();
|
||||
} else {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
return;
|
||||
}
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
{{>header}}
|
||||
{{>part_of}}
|
||||
class OAuth implements Authentication {
|
||||
OAuth({this.accessToken});
|
||||
OAuth({this.accessToken = ''});
|
||||
|
||||
String accessToken;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
{{{classname}}}({
|
||||
{{#vars}}
|
||||
{{!
|
||||
A field is @required in Dart when it is
|
||||
required && !nullable && !defaultValue in OAS
|
||||
A field is required in Dart when it is
|
||||
required && !defaultValue in OAS
|
||||
}}
|
||||
{{#required}}{{^isNullable}}{{^defaultValue}}@required {{/defaultValue}}{{/isNullable}}{{/required}}this.{{{name}}}{{^isNullable}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/isNullable}},
|
||||
{{#required}}{{^defaultValue}}required {{/defaultValue}}{{/required}}this.{{{name}}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{.}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}},
|
||||
{{/vars}}
|
||||
});
|
||||
});
|
||||
|
@ -1,27 +1,17 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool/
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
pubspec.lock # Except for application packages
|
||||
|
||||
# Files created by dart2js
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# rules if you intend to use dart2js directly
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
*.dart.js
|
||||
*.part.js
|
||||
*.js.deps
|
||||
*.js.map
|
||||
*.info.json
|
||||
|
||||
# Directory created by dartdoc
|
||||
doc/api/
|
||||
|
||||
# Don't commit pubspec lock file
|
||||
# (Library packages only! Remove pattern if developing an application package)
|
||||
pubspec.lock
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -7,7 +7,7 @@ import 'package:test/test.dart';
|
||||
// tests for {{{classname}}}
|
||||
void main() {
|
||||
{{^isEnum}}
|
||||
final instance = {{{classname}}}();
|
||||
// final instance = {{{classname}}}();
|
||||
{{/isEnum}}
|
||||
|
||||
group('test {{{classname}}}', () {
|
||||
|
@ -1,21 +1,40 @@
|
||||
class {{{classname}}} {
|
||||
{{>dart_constructor}}
|
||||
|
||||
{{#vars}}
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{^isEnum}}
|
||||
{{#minimum}}
|
||||
// minimum: {{{.}}}
|
||||
{{#description}}
|
||||
///
|
||||
{{/description}}
|
||||
/// Minimum value: {{{.}}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
// maximum: {{{.}}}
|
||||
{{#description}}
|
||||
{{^minimum}}
|
||||
///
|
||||
{{/minimum}}
|
||||
{{/description}}
|
||||
/// Maximum value: {{{.}}}
|
||||
{{/maximum}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{/isEnum}}
|
||||
{{{datatypeWithEnum}}} {{{name}}};
|
||||
{{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isNullable}} {{{name}}};
|
||||
|
||||
{{/vars}}
|
||||
{{/vars}}
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} &&
|
||||
{{#vars}}
|
||||
@ -24,9 +43,9 @@ class {{{classname}}} {
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
// ignore: unnecessary_parenthesis
|
||||
{{#vars}}
|
||||
({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
|
||||
({{#isNullable}}{{{name}}} == null ? 0 : {{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}{{{name}}} == null ? 0 : {{/defaultValue}}{{/required}}{{/isNullable}}{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/vars}}
|
||||
|
||||
@override
|
||||
@ -35,37 +54,51 @@ class {{{classname}}} {
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
{{#vars}}
|
||||
{{^required}}
|
||||
{{#isNullable}}
|
||||
if ({{{name}}} != null) {
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
if ({{{name}}} != null) {
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{#isDateTime}}
|
||||
{{#pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}.millisecondsSinceEpoch
|
||||
: {{{name}}}.toUtc().toIso8601String();
|
||||
json[r'{{{baseName}}}'] = _dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.millisecondsSinceEpoch
|
||||
: {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc().toIso8601String();
|
||||
{{/pattern}}
|
||||
{{^pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}{{{name}}}.toUtc().toIso8601String();
|
||||
json[r'{{{baseName}}}'] = {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc().toIso8601String();
|
||||
{{/pattern}}
|
||||
{{/isDateTime}}
|
||||
{{#isDate}}
|
||||
{{#pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}.millisecondsSinceEpoch
|
||||
: _dateFormatter.format({{{name}}}.toUtc());
|
||||
json[r'{{{baseName}}}'] = _dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.millisecondsSinceEpoch
|
||||
: _dateFormatter.format({{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc());
|
||||
{{/pattern}}
|
||||
{{^pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateFormatter.format({{{name}}}.toUtc());
|
||||
json[r'{{{baseName}}}'] = _dateFormatter.format({{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc());
|
||||
{{/pattern}}
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}{{{name}}};
|
||||
json[r'{{{baseName}}}'] = {{{name}}};
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
{{^required}}
|
||||
{{#isNullable}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
}
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
return json;
|
||||
}
|
||||
@ -73,16 +106,28 @@ class {{{classname}}} {
|
||||
/// Returns a new [{{{classname}}}] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static {{{classname}}} fromJson(dynamic value) {
|
||||
static {{{classname}}}? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "{{{classname}}}[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "{{{classname}}}[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return {{{classname}}}(
|
||||
{{#vars}}
|
||||
{{#isDateTime}}
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'),
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isDateTime}}
|
||||
{{#isDate}}
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'),
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
@ -97,36 +142,36 @@ class {{{classname}}} {
|
||||
{{^items.complexType}}
|
||||
(e) => e == null ? null : (e as List).cast<{{items.items.dataType}}>()
|
||||
{{/items.complexType}}
|
||||
).toList(growable: false)
|
||||
).toList()
|
||||
: null,
|
||||
{{/items.isArray}}
|
||||
{{^items.isArray}}
|
||||
{{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.isArray}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
{{#items.isArray}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] == null
|
||||
? null
|
||||
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
||||
{{#items.complexType}}
|
||||
: {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']),
|
||||
: {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']),
|
||||
{{/items.complexType}}
|
||||
{{^items.complexType}}
|
||||
: mapCastOfType<String, List>(json, r'{{{baseName}}}'),
|
||||
: mapCastOfType<String, List>(json, r'{{{baseName}}}'),
|
||||
{{/items.complexType}}
|
||||
{{/items.isArray}}
|
||||
{{^items.isArray}}
|
||||
{{#items.isMap}}
|
||||
{{#items.complexType}}
|
||||
{{{name}}}: {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.complexType}}
|
||||
{{^items.complexType}}
|
||||
{{{name}}}: mapCastOfType<String, dynamic>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapCastOfType<String, dynamic>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.complexType}}
|
||||
{{/items.isMap}}
|
||||
{{^items.isMap}}
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.isMap}}
|
||||
{{/items.isArray}}
|
||||
{{/isMap}}
|
||||
@ -135,7 +180,7 @@ class {{{classname}}} {
|
||||
{{{name}}}: null, // No support for decoding binary content from JSON
|
||||
{{/isBinary}}
|
||||
{{^isBinary}}
|
||||
{{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isBinary}}
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
@ -143,30 +188,30 @@ class {{{classname}}} {
|
||||
{{^complexType}}
|
||||
{{#isArray}}
|
||||
{{#isEnum}}
|
||||
{{{name}}}: {{{items.datatypeWithEnum}}}.listFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{items.datatypeWithEnum}}}.listFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] is {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}
|
||||
? (json[r'{{{baseName}}}'] as {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}).cast<{{{items.datatype}}}>()
|
||||
: null,
|
||||
? (json[r'{{{baseName}}}'] as {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}).cast<{{{items.datatype}}}>()
|
||||
: {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}},
|
||||
{{/isEnum}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
{{{name}}}: mapCastOfType<String, {{{items.datatype}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapCastOfType<String, {{{items.datatype}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
{{#isNumber}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] == null
|
||||
? null
|
||||
: {{{datatypeWithEnum}}}.parse(json[r'{{{baseName}}}'].toString()),
|
||||
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
||||
: {{{datatypeWithEnum}}}.parse(json[r'{{{baseName}}}'].toString()),
|
||||
{{/isNumber}}
|
||||
{{^isNumber}}
|
||||
{{^isEnum}}
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{/isNumber}}
|
||||
{{/isMap}}
|
||||
@ -180,37 +225,56 @@ class {{{classname}}} {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<{{{classname}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{classname}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{classname}}}>[];
|
||||
static List<{{{classname}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{classname}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{classname}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, {{{classname}}}> mapFromJson(dynamic json) {
|
||||
final map = <String, {{{classname}}}>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = {{{classname}}}.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = {{{classname}}}.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of {{{classname}}}-objects as value to a dart map
|
||||
static Map<String, List<{{{classname}}}>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<{{{classname}}}>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<{{{classname}}}>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = {{{classname}}}.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = {{{classname}}}.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
{{#vars}}
|
||||
{{#required}}
|
||||
'{{{baseName}}}',
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
};
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
@ -225,4 +289,4 @@ class {{{classname}}} {
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/vars}}
|
||||
|
@ -7,7 +7,7 @@ class {{{classname}}} {
|
||||
final {{{dataType}}} value;
|
||||
|
||||
@override
|
||||
String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}};
|
||||
String toString() => {{#isString}}value{{/isString}}{{^isString}}value.toString(){{/isString}};
|
||||
|
||||
{{{dataType}}} toJson() => value;
|
||||
|
||||
@ -26,13 +26,20 @@ class {{{classname}}} {
|
||||
{{/allowableValues}}
|
||||
];
|
||||
|
||||
static {{{classname}}} fromJson(dynamic value) =>
|
||||
{{{classname}}}TypeTransformer().decode(value);
|
||||
static {{{classname}}}? fromJson(dynamic value) => {{{classname}}}TypeTransformer().decode(value);
|
||||
|
||||
static List<{{{classname}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{classname}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{classname}}}>[];
|
||||
static List<{{{classname}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{classname}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{classname}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [{{{classname}}}] to {{{dataType}}},
|
||||
@ -52,7 +59,7 @@ class {{{classname}}}TypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
{{{classname}}} decode(dynamic data, {bool allowNull}) {
|
||||
{{{classname}}}? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
{{#allowableValues}}
|
||||
@ -61,7 +68,7 @@ class {{{classname}}}TypeTransformer {
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -70,5 +77,5 @@ class {{{classname}}}TypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [{{{classname}}}TypeTransformer] instance.
|
||||
static {{{classname}}}TypeTransformer _instance;
|
||||
static {{{classname}}}TypeTransformer? _instance;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class {{{enumName}}} {
|
||||
final {{{dataType}}} value;
|
||||
|
||||
@override
|
||||
String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}};
|
||||
String toString() => {{#isString}}value{{/isString}}{{^isString}}value.toString(){{/isString}};
|
||||
|
||||
{{{dataType}}} toJson() => value;
|
||||
|
||||
@ -26,13 +26,20 @@ class {{{enumName}}} {
|
||||
{{/allowableValues}}
|
||||
];
|
||||
|
||||
static {{{enumName}}} fromJson(dynamic value) =>
|
||||
{{{enumName}}}TypeTransformer().decode(value);
|
||||
static {{{enumName}}}? fromJson(dynamic value) => {{{enumName}}}TypeTransformer().decode(value);
|
||||
|
||||
static List<{{{enumName}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{enumName}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{enumName}}}>[];
|
||||
static List<{{{enumName}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{enumName}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{enumName}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [{{{enumName}}}] to {{{dataType}}},
|
||||
@ -52,7 +59,7 @@ class {{{enumName}}}TypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
{{{enumName}}} decode(dynamic data, {bool allowNull}) {
|
||||
{{{enumName}}}? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
{{#allowableValues}}
|
||||
@ -61,7 +68,7 @@ class {{{enumName}}}TypeTransformer {
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -70,5 +77,5 @@ class {{{enumName}}}TypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [{{{enumName}}}TypeTransformer] instance.
|
||||
static {{{enumName}}}TypeTransformer _instance;
|
||||
static {{{enumName}}}TypeTransformer? _instance;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "2.2.0"
|
||||
- "2.12"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
|
@ -22,7 +22,7 @@ type {{classname}}Router interface { {{#operations}}{{#operation}}
|
||||
|
||||
// {{classname}}Servicer defines the api actions for the {{classname}} service
|
||||
// This interface intended to stay up to date with the openapi yaml used to generate it,
|
||||
// while the service implementation can ignored with the .openapi-generator-ignore file
|
||||
// while the service implementation can be ignored with the .openapi-generator-ignore file
|
||||
// and updated with the logic required for the API.
|
||||
type {{classname}}Servicer interface { {{#operations}}{{#operation}}
|
||||
{{#isDeprecated}}
|
||||
|
@ -46,7 +46,7 @@ func New{{classname}}Controller(s {{classname}}Servicer, opts ...{{classname}}Op
|
||||
return controller
|
||||
}
|
||||
|
||||
// Routes returns all of the api route for the {{classname}}Controller
|
||||
// Routes returns all the api routes for the {{classname}}Controller
|
||||
func (c *{{classname}}Controller) Routes() Routes {
|
||||
return Routes{ {{#operations}}{{#operation}}
|
||||
{
|
||||
@ -130,10 +130,33 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
||||
return
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{#isArray}}
|
||||
{{#items.isLong}}
|
||||
{{paramName}}Param, err := parseInt64ArrayParameter(query.Get("{{baseName}}"), ",", {{required}})
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
{{/items.isLong}}
|
||||
{{#items.isInteger}}
|
||||
{{paramName}}Param, err := parseInt32ArrayParameter(query.Get("{{baseName}}"), ",", {{required}})
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
{{/items.isInteger}}
|
||||
{{^items.isLong}}
|
||||
{{^items.isInteger}}
|
||||
{{paramName}}Param := strings.Split(query.Get("{{baseName}}"), ",")
|
||||
{{/items.isInteger}}
|
||||
{{/items.isLong}}
|
||||
{{/isArray}}
|
||||
{{^isLong}}
|
||||
{{^isInteger}}
|
||||
{{^isBoolean}}
|
||||
{{paramName}}Param := {{#isArray}}strings.Split({{/isArray}}query.Get("{{baseName}}"){{#isArray}}, ","){{/isArray}}
|
||||
{{^isArray}}
|
||||
{{paramName}}Param := query.Get("{{baseName}}")
|
||||
{{/isArray}}
|
||||
{{/isBoolean}}
|
||||
{{/isInteger}}
|
||||
{{/isLong}}
|
||||
|
@ -32,13 +32,13 @@ func IsZeroValue(val interface{}) bool {
|
||||
return val == nil || reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
|
||||
}
|
||||
|
||||
// AssertInterfaceRequired recursively checks each struct in a slice against the callback.
|
||||
// AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback.
|
||||
// This method traverse nested slices in a preorder fashion.
|
||||
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error {
|
||||
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
|
||||
}
|
||||
|
||||
// AssertNestedValueRequired checks each struct in the nested slice against the callback.
|
||||
// AssertRecurseValueRequired checks each struct in the nested slice against the callback.
|
||||
// This method traverse nested slices in a preorder fashion.
|
||||
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error {
|
||||
switch value.Kind() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
|
||||
//Implementation response defines an error code with the associated body
|
||||
// ImplResponse response defines an error code with the associated body
|
||||
type ImplResponse struct {
|
||||
Code int
|
||||
{{#addResponseHeaders}}
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
|
||||
"module": "commonjs",
|
||||
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
||||
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
|
@ -9,7 +9,6 @@ import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.languages.AbstractKotlinCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinClientCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinServerCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinServerDeprecatedCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinSpringServerCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinVertxServerCodegen;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@ -29,7 +28,6 @@ public class KotlinModelCodegenTest {
|
||||
return new Object[][]{
|
||||
{new KotlinClientCodegen()},
|
||||
{new KotlinServerCodegen()},
|
||||
{new KotlinServerDeprecatedCodegen()},
|
||||
{new KotlinSpringServerCodegen()},
|
||||
{new KotlinVertxServerCodegen()},
|
||||
};
|
||||
@ -90,7 +88,7 @@ public class KotlinModelCodegenTest {
|
||||
String outputPath = generateModels(codegen, "src/test/resources/3_0/issue_9848.yaml", false);
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/models/NonUniqueArray.kt"),
|
||||
codegen instanceof KotlinVertxServerCodegen || codegen instanceof KotlinServerDeprecatedCodegen
|
||||
codegen instanceof KotlinVertxServerCodegen
|
||||
? "val array: kotlin.Array<kotlin.String>"
|
||||
: "val array: kotlin.collections.List<kotlin.String>"
|
||||
);
|
||||
@ -104,7 +102,7 @@ public class KotlinModelCodegenTest {
|
||||
String outputPath = generateModels(codegen, "src/test/resources/3_0/issue_9848.yaml", true);
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/models/NonUniqueArray.kt"),
|
||||
codegen instanceof KotlinVertxServerCodegen || codegen instanceof KotlinServerDeprecatedCodegen
|
||||
codegen instanceof KotlinVertxServerCodegen
|
||||
? "var array: kotlin.Array<kotlin.String>"
|
||||
: "var array: kotlin.collections.MutableList<kotlin.String>"
|
||||
);
|
||||
@ -112,26 +110,4 @@ public class KotlinModelCodegenTest {
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/models/UniqueArray.kt"),
|
||||
"var array: kotlin.collections.MutableSet<kotlin.String>");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "generators")
|
||||
public void mutableContainerTypes(AbstractKotlinCodegen codegen) throws IOException {
|
||||
final String outputPath = generateModels(codegen, "src/test/resources/3_0/kotlin/issue11088-model-mutable-with-containers.yaml", true);
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/models/MyModel.kt"),
|
||||
codegen instanceof KotlinVertxServerCodegen || codegen instanceof KotlinServerDeprecatedCodegen
|
||||
? "var myIntArray: kotlin.Array<kotlin.Int>?"
|
||||
: "var myIntArray: kotlin.collections.MutableList<kotlin.Int>?",
|
||||
"var myStringSet: kotlin.collections.MutableSet<kotlin.String>?",
|
||||
"var myFreeFormObjectWithPrimitiveValues: kotlin.collections.MutableMap<kotlin.String, kotlin.Int>?",
|
||||
"var myFreeFormObjectWithComplexValues: kotlin.collections.MutableMap<kotlin.String, MyModelMyFreeFormObjectWithComplexValues>?",
|
||||
"var myFreeFormObject: kotlin.collections.MutableMap<kotlin.String, kotlin.Any>?"
|
||||
);
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/kotlin/models/MyModelMyFreeFormObjectWithComplexValues.kt"),
|
||||
codegen instanceof KotlinVertxServerCodegen || codegen instanceof KotlinServerDeprecatedCodegen
|
||||
? "var myArrayOfInts: kotlin.Array<kotlin.Int>?"
|
||||
: "var myArrayOfInts: kotlin.collections.MutableList<kotlin.Int>?",
|
||||
"var mySetOfStrings: kotlin.collections.MutableSet<kotlin.String>?"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.silex;
|
||||
|
||||
import org.openapitools.codegen.AbstractOptionsTest;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.languages.PhpSilexServerCodegen;
|
||||
import org.openapitools.codegen.options.PhpSilexServerOptionsProvider;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class PhpSilexServerOptionsTest extends AbstractOptionsTest {
|
||||
private PhpSilexServerCodegen clientCodegen = mock(PhpSilexServerCodegen.class, mockSettings);
|
||||
|
||||
public PhpSilexServerOptionsTest() {
|
||||
super(new PhpSilexServerOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void verifyOptions() {
|
||||
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(PhpSilexServerOptionsProvider.SORT_PARAMS_VALUE));
|
||||
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(PhpSilexServerOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.typescript.typescriptangularjs;
|
||||
|
||||
import org.openapitools.codegen.AbstractOptionsTest;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.languages.TypeScriptAngularJsClientCodegen;
|
||||
import org.openapitools.codegen.options.TypeScriptAngularJsClientOptionsProvider;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class TypeScriptAngularJsClientOptionsTest extends AbstractOptionsTest {
|
||||
private TypeScriptAngularJsClientCodegen clientCodegen = mock(TypeScriptAngularJsClientCodegen.class, mockSettings);
|
||||
|
||||
public TypeScriptAngularJsClientOptionsTest() {
|
||||
super(new TypeScriptAngularJsClientOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void verifyOptions() {
|
||||
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.SORT_PARAMS_VALUE));
|
||||
verify(clientCodegen).setModelPropertyNaming(TypeScriptAngularJsClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
|
||||
verify(clientCodegen).setParamNaming(TypeScriptAngularJsClientOptionsProvider.PARAM_NAMING_VALUE);
|
||||
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.SUPPORTS_ES6_VALUE));
|
||||
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
|
||||
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptAngularJsClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
|
||||
}
|
||||
}
|
@ -1,286 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.typescript.typescriptangularjs;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.languages.TypeScriptAngularJsClientCodegen;
|
||||
import org.openapitools.codegen.languages.TypeScriptFetchClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public class TypeScriptAngularJsModelTest {
|
||||
|
||||
@Test(description = "convert a simple TypeScript Angular model")
|
||||
public void simpleModelTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addProperties("active", new BooleanSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 5);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "number");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertEquals(property1.defaultValue, "undefined");
|
||||
Assert.assertEquals(property1.baseType, "number");
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.dataType, "string");
|
||||
Assert.assertEquals(property2.name, "name");
|
||||
Assert.assertEquals(property2.defaultValue, "undefined");
|
||||
Assert.assertEquals(property2.baseType, "string");
|
||||
Assert.assertTrue(property2.required);
|
||||
Assert.assertFalse(property2.isContainer);
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(property3.complexType, null);
|
||||
Assert.assertEquals(property3.dataType, "string");
|
||||
Assert.assertEquals(property3.name, "createdAt");
|
||||
Assert.assertEquals(property3.defaultValue, "undefined");
|
||||
Assert.assertFalse(property3.required);
|
||||
Assert.assertFalse(property3.isContainer);
|
||||
|
||||
final CodegenProperty property4 = cm.vars.get(3);
|
||||
Assert.assertEquals(property4.baseName, "birthDate");
|
||||
Assert.assertEquals(property4.complexType, null);
|
||||
Assert.assertEquals(property4.dataType, "string");
|
||||
Assert.assertEquals(property4.name, "birthDate");
|
||||
Assert.assertEquals(property4.defaultValue, "undefined");
|
||||
Assert.assertFalse(property4.required);
|
||||
Assert.assertFalse(property4.isContainer);
|
||||
|
||||
final CodegenProperty property5 = cm.vars.get(4);
|
||||
Assert.assertEquals(property5.baseName, "active");
|
||||
Assert.assertEquals(property5.complexType, null);
|
||||
Assert.assertEquals(property5.dataType, "boolean");
|
||||
Assert.assertEquals(property5.name, "active");
|
||||
Assert.assertEquals(property5.defaultValue, "undefined");
|
||||
Assert.assertFalse(property5.required);
|
||||
Assert.assertFalse(property5.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert and check default values for a simple TypeScript Angular model")
|
||||
public void simpleModelDefaultValuesTest() throws ParseException {
|
||||
IntegerSchema integerSchema = new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT);
|
||||
integerSchema.setDefault(1234);
|
||||
|
||||
StringSchema stringSchema = new StringSchema();
|
||||
stringSchema.setDefault("Jack");
|
||||
|
||||
OffsetDateTime testOffsetDateTime = OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 12, 0), ZoneOffset.UTC);
|
||||
DateTimeSchema dateTimeSchema = new DateTimeSchema();
|
||||
dateTimeSchema.setDefault(testOffsetDateTime);
|
||||
|
||||
Date testDate = Date.from(testOffsetDateTime.toInstant());
|
||||
DateSchema dateSchema = new DateSchema();
|
||||
dateSchema.setDefault(testDate);
|
||||
|
||||
BooleanSchema booleanSchema = new BooleanSchema();
|
||||
booleanSchema.setDefault(true);
|
||||
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", integerSchema)
|
||||
.addProperties("name", stringSchema)
|
||||
.addProperties("createdAt", dateTimeSchema)
|
||||
.addProperties("birthDate", dateSchema)
|
||||
.addProperties("active", booleanSchema)
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 5);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.defaultValue, "1234");
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.defaultValue, "'Jack'");
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(OffsetDateTime.parse(property3.defaultValue), testOffsetDateTime);
|
||||
|
||||
final CodegenProperty property4 = cm.vars.get(3);
|
||||
Assert.assertEquals(property4.baseName, "birthDate");
|
||||
Assert.assertEquals(new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH).parse(property4.defaultValue), testDate);
|
||||
|
||||
final CodegenProperty property5 = cm.vars.get(4);
|
||||
Assert.assertEquals(property5.baseName, "active");
|
||||
Assert.assertEquals(property5.defaultValue, "true");
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with list property")
|
||||
public void listPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema().items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "number");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertEquals(property1.defaultValue, "undefined");
|
||||
Assert.assertEquals(property1.baseType, "number");
|
||||
Assert.assertTrue(property1.required);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "urls");
|
||||
Assert.assertEquals(property2.dataType, "Array<string>");
|
||||
Assert.assertEquals(property2.name, "urls");
|
||||
Assert.assertEquals(property2.baseType, "Array");
|
||||
Assert.assertFalse(property2.required);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex property")
|
||||
public void complexPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.dataType, "models.Children");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.defaultValue, "undefined");
|
||||
Assert.assertEquals(property1.baseType, "models.Children");
|
||||
Assert.assertFalse(property1.required);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex list property")
|
||||
public void complexListPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "models.Children");
|
||||
Assert.assertEquals(property1.dataType, "Array<models.Children>");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "Array");
|
||||
Assert.assertFalse(property1.required);
|
||||
}
|
||||
|
||||
@Test(description = "convert an array model")
|
||||
public void arrayModelTest() {
|
||||
final Schema schema = new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children"))
|
||||
.description("an array model");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "an array model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
}
|
||||
|
||||
@Test(description = "convert a map model")
|
||||
public void mapModelTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a map model")
|
||||
.additionalProperties(new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngularJsClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a map model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("models.Children")).size(), 1);
|
||||
}
|
||||
}
|
5
pom.xml
5
pom.xml
@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>5.4.0</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
@ -1346,7 +1346,7 @@
|
||||
<module>samples/openapi3/client/petstore/java/jersey2-java8</module>
|
||||
<module>samples/client/others/java/okhttp-gson-streaming</module>
|
||||
<module>samples/client/petstore/java/okhttp-gson</module>
|
||||
<module>samples/client/petstore/java/okhttp-gson-nextgen</module>
|
||||
<!--<module>samples/client/petstore/java/okhttp-gson-nextgen</module>-->
|
||||
<module>samples/client/petstore/java/retrofit2</module>
|
||||
<module>samples/client/petstore/java/retrofit2rx2</module>
|
||||
<module>samples/client/petstore/java/retrofit2rx3</module>
|
||||
@ -1449,7 +1449,6 @@
|
||||
</activation>
|
||||
<modules>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore</module>
|
||||
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake</module>
|
||||
</modules>
|
||||
</profile>
|
||||
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -39,7 +39,7 @@ public class ServerConfiguration {
|
||||
if (variables != null && variables.containsKey(name)) {
|
||||
value = variables.get(name);
|
||||
if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
|
||||
throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
|
||||
throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + ".");
|
||||
}
|
||||
}
|
||||
url = url.replaceAll("\\{" + name + "\\}", value);
|
||||
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
@ -1 +1 @@
|
||||
5.4.0
|
||||
6.0.0-SNAPSHOT
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user