forked from loafle/openapi-generator-original
Merge branch 'master' into typescript-refactor-master
This commit is contained in:
commit
71c3cad24b
@ -32,7 +32,7 @@ install:
|
|||||||
- git clone https://github.com/wing328/swagger-samples
|
- git clone https://github.com/wing328/swagger-samples
|
||||||
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
|
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
|
||||||
- ps: $PSVersionTable.PSVersion
|
- ps: $PSVersionTable.PSVersion
|
||||||
- ps: Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.3.1
|
- ps: Install-Module Pester -Force -Scope CurrentUser
|
||||||
build_script:
|
build_script:
|
||||||
- dotnet --info
|
- dotnet --info
|
||||||
# build C# API client (netcore)
|
# build C# API client (netcore)
|
||||||
|
@ -12,6 +12,7 @@ sidebar_label: go-experimental
|
|||||||
|packageVersion|Go package version.| |1.0.0|
|
|packageVersion|Go package version.| |1.0.0|
|
||||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||||
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts => PetApiDeletePetOpts| |false|
|
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts => PetApiDeletePetOpts| |false|
|
||||||
|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |false|
|
||||||
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|
||||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
|
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
|
||||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||||
|
@ -11,6 +11,7 @@ sidebar_label: powershell
|
|||||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||||
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
||||||
|powershellGalleryUrl|URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/).| |null|
|
|powershellGalleryUrl|URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/).| |null|
|
||||||
|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |null|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ npm install @openapitools/openapi-generator-cli -D
|
|||||||
Then, **generate** a ruby client from a valid [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml) doc:
|
Then, **generate** a ruby client from a valid [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml) doc:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx openapi-generator generate -i petstore.yaml -g ruby -o /tmp/test/
|
npx @openapitools/openapi-generator-cli generate -i petstore.yaml -g ruby -o /tmp/test/
|
||||||
```
|
```
|
||||||
|
|
||||||
> `npx` will execute a globally available `openapi-generator`, and if not found it will fall back to project-local commands. The result is that the above command will work regardless of which installation method you've chosen.
|
> `npx` will execute a globally available `openapi-generator`, and if not found it will fall back to project-local commands. The result is that the above command will work regardless of which installation method you've chosen.
|
||||||
|
@ -230,7 +230,7 @@ public class Generate extends OpenApiGeneratorCommand {
|
|||||||
@Option(name = {"--log-to-stderr"},
|
@Option(name = {"--log-to-stderr"},
|
||||||
title = "Log to STDERR",
|
title = "Log to STDERR",
|
||||||
description = "write all log messages (not just errors) to STDOUT."
|
description = "write all log messages (not just errors) to STDOUT."
|
||||||
+ " Useful for piping the JSON output of debug options (e.g. `-DdebugOperations`) to an external parser directly while testing a generator.")
|
+ " Useful for piping the JSON output of debug options (e.g. `--global-property debugOperations`) to an external parser directly while testing a generator.")
|
||||||
private Boolean logToStderr;
|
private Boolean logToStderr;
|
||||||
|
|
||||||
@Option(name = {"--enable-post-process-file"}, title = "enable post-process file", description = CodegenConstants.ENABLE_POST_PROCESS_FILE_DESC)
|
@Option(name = {"--enable-post-process-file"}, title = "enable post-process file", description = CodegenConstants.ENABLE_POST_PROCESS_FILE_DESC)
|
||||||
@ -407,7 +407,6 @@ public class Generate extends OpenApiGeneratorCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (globalProperties != null && !globalProperties.isEmpty()) {
|
if (globalProperties != null && !globalProperties.isEmpty()) {
|
||||||
System.err.println("[DEPRECATED] -D arguments after 'generate' are application arguments and not Java System Properties, please consider changing to --global-property, apply your system properties to JAVA_OPTS, or move the -D arguments before the jar option.");
|
|
||||||
applyGlobalPropertiesKvpList(globalProperties, configurator);
|
applyGlobalPropertiesKvpList(globalProperties, configurator);
|
||||||
}
|
}
|
||||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||||
|
@ -375,4 +375,6 @@ public class CodegenConstants {
|
|||||||
" 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed." +
|
" 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed." +
|
||||||
"Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.";
|
"Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.";
|
||||||
|
|
||||||
|
public static final String USE_ONEOF_DISCRIMINATOR_LOOKUP = "useOneOfDiscriminatorLookup";
|
||||||
|
public static final String USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC = "Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.";
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.openapitools.codegen.utils.OnceLogger.once;
|
|
||||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
"byte",
|
"byte",
|
||||||
"map[string]interface{}",
|
"map[string]interface{}",
|
||||||
"interface{}"
|
"interface{}"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
instantiationTypes.clear();
|
instantiationTypes.clear();
|
||||||
@ -210,6 +209,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
if (name.matches("^\\d.*"))
|
if (name.matches("^\\d.*"))
|
||||||
name = "Var" + name;
|
name = "Var" + name;
|
||||||
|
|
||||||
|
if ("AdditionalProperties".equals(name)) {
|
||||||
|
// AdditionalProperties is a reserved field (additionalProperties: true), use AdditionalPropertiesField instead
|
||||||
|
return "AdditionalPropertiesField";
|
||||||
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +324,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the golang implementation type for the specified property.
|
* Return the golang implementation type for the specified property.
|
||||||
*
|
*
|
||||||
* @param p the OAS property.
|
* @param p the OAS property.
|
||||||
* @return the golang implementation type.
|
* @return the golang implementation type.
|
||||||
*/
|
*/
|
||||||
@ -378,7 +382,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OpenAPI type for the property.
|
* Return the OpenAPI type for the property.
|
||||||
*
|
*
|
||||||
* @param p the OAS property.
|
* @param p the OAS property.
|
||||||
* @return the OpenAPI type.
|
* @return the OpenAPI type.
|
||||||
*/
|
*/
|
||||||
@ -404,20 +408,19 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the golang instantiation type of the specified schema.
|
* Determines the golang instantiation type of the specified schema.
|
||||||
*
|
* <p>
|
||||||
* This function is called when the input schema is a map, and specifically
|
* This function is called when the input schema is a map, and specifically
|
||||||
* when the 'additionalProperties' attribute is present in the OAS specification.
|
* when the 'additionalProperties' attribute is present in the OAS specification.
|
||||||
* Codegen invokes this function to resolve the "parent" association to
|
* Codegen invokes this function to resolve the "parent" association to
|
||||||
* 'additionalProperties'.
|
* 'additionalProperties'.
|
||||||
*
|
* <p>
|
||||||
* Note the 'parent' attribute in the codegen model is used in the following scenarios:
|
* Note the 'parent' attribute in the codegen model is used in the following scenarios:
|
||||||
* - Indicate a polymorphic association with some other type (e.g. class inheritance).
|
* - Indicate a polymorphic association with some other type (e.g. class inheritance).
|
||||||
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
|
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
|
||||||
* - Use of the 'additionalProperties' attribute in the OAS specification.
|
* - Use of the 'additionalProperties' attribute in the OAS specification.
|
||||||
* This is the specific scenario when codegen invokes this function.
|
* This is the specific scenario when codegen invokes this function.
|
||||||
*
|
*
|
||||||
* @param property the input schema
|
* @param property the input schema
|
||||||
*
|
|
||||||
* @return the golang instantiation type of the specified property.
|
* @return the golang instantiation type of the specified property.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -497,13 +497,20 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
|||||||
name = name.toLowerCase(Locale.ROOT);
|
name = name.toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Unreal variable names are CamelCase
|
||||||
|
String camelCaseName = camelize(name, false);
|
||||||
|
|
||||||
|
//Avoid empty variable name at all costs
|
||||||
|
if(!camelCaseName.isEmpty()) {
|
||||||
|
name = camelCaseName;
|
||||||
|
}
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word or word starting with number, append _
|
||||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
name = escapeReservedWord(name);
|
name = escapeReservedWord(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unreal variable names are CamelCase
|
return name;
|
||||||
return camelize(name, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,7 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
|
||||||
protected String goImportAlias = "openapiclient";
|
protected String goImportAlias = "openapiclient";
|
||||||
|
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||||
|
|
||||||
public GoClientExperimentalCodegen() {
|
public GoClientExperimentalCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -44,6 +45,8 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
usesOptionals = false;
|
usesOptionals = false;
|
||||||
|
|
||||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build();
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build();
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,6 +96,20 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
additionalProperties.put("goImportAlias", goImportAlias);
|
additionalProperties.put("goImportAlias", goImportAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP)) {
|
||||||
|
setUseOneOfDiscriminatorLookup(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseOneOfDiscriminatorLookup(boolean useOneOfDiscriminatorLookup) {
|
||||||
|
this.useOneOfDiscriminatorLookup = useOneOfDiscriminatorLookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getUseOneOfDiscriminatorLookup() {
|
||||||
|
return this.useOneOfDiscriminatorLookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoImportAlias(String goImportAlias) {
|
public void setGoImportAlias(String goImportAlias) {
|
||||||
@ -205,9 +222,12 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
||||||
imports.add(createMapping("import", "fmt"));
|
imports.add(createMapping("import", "fmt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add x-additional-properties
|
||||||
|
if ("map[string]map[string]interface{}".equals(model.parent)) {
|
||||||
|
model.vendorExtensions.put("x-additional-properties", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
protected HashSet powershellVerbs;
|
protected HashSet powershellVerbs;
|
||||||
protected Map<String, String> commonVerbs; // verbs not in the official ps verb list but can be mapped to one of the verbs
|
protected Map<String, String> commonVerbs; // verbs not in the official ps verb list but can be mapped to one of the verbs
|
||||||
protected HashSet methodNames; // store a list of method names to detect duplicates
|
protected HashSet methodNames; // store a list of method names to detect duplicates
|
||||||
|
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance of `PowerShellClientCodegen`.
|
* Constructs an instance of `PowerShellClientCodegen`.
|
||||||
@ -498,7 +499,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_PROJECT_GUID, "GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default."));
|
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_PROJECT_GUID, "GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default."));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, "Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet."));
|
cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, "Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet."));
|
||||||
cliOptions.add(new CliOption("commonVerbs", "PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly."));
|
cliOptions.add(new CliOption("commonVerbs", "PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly."));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
@ -535,6 +536,14 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
this.powershellGalleryUrl = powershellGalleryUrl;
|
this.powershellGalleryUrl = powershellGalleryUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseOneOfDiscriminatorLookup(boolean useOneOfDiscriminatorLookup) {
|
||||||
|
this.useOneOfDiscriminatorLookup = useOneOfDiscriminatorLookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getUseOneOfDiscriminatorLookup() {
|
||||||
|
return this.useOneOfDiscriminatorLookup;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
@ -550,6 +559,12 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
additionalProperties.put("powershellGalleryUrl", powershellGalleryUrl);
|
additionalProperties.put("powershellGalleryUrl", powershellGalleryUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP)) {
|
||||||
|
setUseOneOfDiscriminatorLookup(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
||||||
// get the last segment of the URL
|
// get the last segment of the URL
|
||||||
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
||||||
@ -907,6 +922,31 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
model.anyOf.remove("ModelNull");
|
model.anyOf.remove("ModelNull");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add vendor extension for additonalProperties: true
|
||||||
|
if ("null<String, SystemCollectionsHashtable>".equals(model.parent)) {
|
||||||
|
model.vendorExtensions.put("x-additional-properties", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// automatically create discriminator mapping for oneOf/anyOf if not present
|
||||||
|
if (((model.oneOf != null && !model.oneOf.isEmpty()) || (model.anyOf != null && !model.anyOf.isEmpty())) &&
|
||||||
|
model.discriminator != null && model.discriminator.getMapping() == null) {
|
||||||
|
// create mappedModels
|
||||||
|
Set<String> schemas = new HashSet<>();
|
||||||
|
if (model.oneOf != null && !model.oneOf.isEmpty()) {
|
||||||
|
schemas = model.oneOf;
|
||||||
|
} else if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
||||||
|
schemas = model.anyOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<CodegenDiscriminator.MappedModel> mappedModels = new HashSet<>();
|
||||||
|
|
||||||
|
for (String s: schemas) {
|
||||||
|
mappedModels.add(new CodegenDiscriminator.MappedModel(s, s));
|
||||||
|
}
|
||||||
|
|
||||||
|
model.discriminator.setMappedModels(mappedModels);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return objs;
|
return objs;
|
||||||
|
@ -722,7 +722,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// correct "'"s into "'"s after toString()
|
// correct "'"s into "'"s after toString()
|
||||||
if (ModelUtils.isStringSchema(schema) && schema.getDefault() != null) {
|
if (ModelUtils.isStringSchema(schema) && schema.getDefault() != null && !ModelUtils.isDateSchema(schema) && !ModelUtils.isDateTimeSchema(schema)) {
|
||||||
example = (String) schema.getDefault();
|
example = (String) schema.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,9 @@ import org.openapitools.codegen.meta.Stability;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.time.OffsetDateTime;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -196,15 +197,15 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
return "python-experimental";
|
return "python-experimental";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dateToString(Schema p, Date date, DateFormat dateFormatter, DateFormat dateTimeFormatter) {
|
public String dateToString(Schema p, OffsetDateTime date, DateTimeFormatter dateFormatter, DateTimeFormatter dateTimeFormatter) {
|
||||||
// converts a date into a date or date-time python string
|
// converts a date into a date or date-time python string
|
||||||
if (!(ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p))) {
|
if (!(ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p))) {
|
||||||
throw new RuntimeException("passed schema must be of type Date or DateTime");
|
throw new RuntimeException("passed schema must be of type Date or DateTime");
|
||||||
}
|
}
|
||||||
if (ModelUtils.isDateSchema(p)) {
|
if (ModelUtils.isDateSchema(p)) {
|
||||||
return "dateutil_parser('" + dateFormatter.format(date) + "').date()";
|
return "dateutil_parser('" + date.format(dateFormatter) + "').date()";
|
||||||
}
|
}
|
||||||
return "dateutil_parser('" + dateTimeFormatter.format(date) + "')";
|
return "dateutil_parser('" + date.format(dateTimeFormatter) + "')";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,20 +229,17 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert datetime and date enums if they exist
|
// convert datetime and date enums if they exist
|
||||||
DateFormat iso8601Date = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
|
DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE;
|
||||||
DateFormat iso8601DateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT);
|
DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME;
|
||||||
TimeZone utc = TimeZone.getTimeZone("UTC");
|
|
||||||
iso8601Date.setTimeZone(utc);
|
|
||||||
iso8601DateTime.setTimeZone(utc);
|
|
||||||
|
|
||||||
if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) {
|
if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) {
|
||||||
List<Object> currentEnum = p.getEnum();
|
List<Object> currentEnum = p.getEnum();
|
||||||
List<String> fixedEnum = new ArrayList<String>();
|
List<String> fixedEnum = new ArrayList<String>();
|
||||||
String fixedValue = null;
|
String fixedValue = null;
|
||||||
Date date = null;
|
OffsetDateTime date = null;
|
||||||
if (currentEnum != null && !currentEnum.isEmpty()) {
|
if (currentEnum != null && !currentEnum.isEmpty()) {
|
||||||
for (Object enumItem : currentEnum) {
|
for (Object enumItem : currentEnum) {
|
||||||
date = (Date) enumItem;
|
date = (OffsetDateTime) enumItem;
|
||||||
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
||||||
fixedEnum.add(fixedValue);
|
fixedEnum.add(fixedValue);
|
||||||
}
|
}
|
||||||
@ -251,15 +249,21 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
// convert the example if it exists
|
// convert the example if it exists
|
||||||
Object currentExample = p.getExample();
|
Object currentExample = p.getExample();
|
||||||
if (currentExample != null) {
|
if (currentExample != null) {
|
||||||
date = (Date) currentExample;
|
try {
|
||||||
|
date = (OffsetDateTime) currentExample;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
date = ((Date) currentExample).toInstant().atOffset(ZoneOffset.UTC);
|
||||||
|
LOGGER.warn("Invalid `date-time` format for value {}", currentExample);
|
||||||
|
}
|
||||||
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
||||||
fixedEnum.add(fixedValue);
|
fixedEnum.add(fixedValue);
|
||||||
p.setExample(fixedValue);
|
p.setExample(fixedValue);
|
||||||
|
LOGGER.warn(fixedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix defaultObject
|
// fix defaultObject
|
||||||
if (defaultObject != null) {
|
if (defaultObject != null) {
|
||||||
date = (Date) defaultObject;
|
date = (OffsetDateTime) defaultObject;
|
||||||
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
||||||
p.setDefault(fixedValue);
|
p.setDefault(fixedValue);
|
||||||
defaultObject = fixedValue;
|
defaultObject = fixedValue;
|
||||||
@ -377,7 +381,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Override with special post-processing for all models.
|
* Override with special post-processing for all models.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"static-method", "unchecked"})
|
@SuppressWarnings({"static-method", "unchecked"})
|
||||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||||
// loop through all models and delete ones where type!=object and the model has no validations and enums
|
// loop through all models and delete ones where type!=object and the model has no validations and enums
|
||||||
@ -417,14 +421,12 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
|
|
||||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||||
|
|
||||||
if (cm.isEnum || cm.isAlias) {
|
if (cm.isEnum || cm.isAlias) {
|
||||||
if (!modelProperty.isEnum && !modelProperty.hasValidation) {
|
if (!modelProperty.isEnum && !modelProperty.hasValidation && !cm.isArrayModel) {
|
||||||
// remove these models because they are aliases and do not have any enums or validations
|
// remove these models because they are aliases and do not have any enums or validations
|
||||||
modelSchemasToRemove.put(cm.name, modelSchema);
|
modelSchemasToRemove.put(cm.name, modelSchema);
|
||||||
}
|
}
|
||||||
} else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) {
|
|
||||||
// remove any ArrayModels which lack validation and enums
|
|
||||||
modelSchemasToRemove.put(cm.name, modelSchema);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -825,10 +827,10 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
result.unescapedDescription = simpleModelName(name);
|
result.unescapedDescription = simpleModelName(name);
|
||||||
|
|
||||||
// make non-object type models have one property so we can use it to store enums and validations
|
// make non-object type models have one property so we can use it to store enums and validations
|
||||||
if (result.isAlias || result.isEnum) {
|
if (result.isAlias || result.isEnum || result.isArrayModel) {
|
||||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
|
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
|
||||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||||
if (modelProperty.isEnum == true || modelProperty.hasValidation == true) {
|
if (modelProperty.isEnum == true || modelProperty.hasValidation == true || result.isArrayModel) {
|
||||||
// these models are non-object models with enums and/or validations
|
// these models are non-object models with enums and/or validations
|
||||||
// add a single property to the model so we can have a way to access validations
|
// add a single property to the model so we can have a way to access validations
|
||||||
result.isAlias = true;
|
result.isAlias = true;
|
||||||
@ -843,7 +845,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
postProcessModelProperty(result, prop);
|
postProcessModelProperty(result, prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,7 +906,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
* Primitive types in the OAS specification are implemented in Python using the corresponding
|
* Primitive types in the OAS specification are implemented in Python using the corresponding
|
||||||
* Python primitive types.
|
* Python primitive types.
|
||||||
* Composed types (e.g. allAll, oneOf, anyOf) are represented in Python using list of types.
|
* Composed types (e.g. allAll, oneOf, anyOf) are represented in Python using list of types.
|
||||||
*
|
*
|
||||||
* The caller should set the prefix and suffix arguments to empty string, except when
|
* The caller should set the prefix and suffix arguments to empty string, except when
|
||||||
* getTypeString invokes itself recursively. A non-empty prefix/suffix may be specified
|
* getTypeString invokes itself recursively. A non-empty prefix/suffix may be specified
|
||||||
* to wrap the return value in a python dict, list or tuple.
|
* to wrap the return value in a python dict, list or tuple.
|
||||||
@ -913,7 +914,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
* Examples:
|
* Examples:
|
||||||
* - "bool, date, float" The data must be a bool, date or float.
|
* - "bool, date, float" The data must be a bool, date or float.
|
||||||
* - "[bool, date]" The data must be an array, and the array items must be a bool or date.
|
* - "[bool, date]" The data must be an array, and the array items must be a bool or date.
|
||||||
*
|
*
|
||||||
* @param p The OAS schema.
|
* @param p The OAS schema.
|
||||||
* @param prefix prepended to the returned value.
|
* @param prefix prepended to the returned value.
|
||||||
* @param suffix appended to the returned value.
|
* @param suffix appended to the returned value.
|
||||||
@ -922,7 +923,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
* @return a comma-separated string representation of the Python types
|
* @return a comma-separated string representation of the Python types
|
||||||
*/
|
*/
|
||||||
private String getTypeString(Schema p, String prefix, String suffix, List<String> referencedModelNames) {
|
private String getTypeString(Schema p, String prefix, String suffix, List<String> referencedModelNames) {
|
||||||
// this is used to set dataType, which defines a python tuple of classes
|
|
||||||
String fullSuffix = suffix;
|
String fullSuffix = suffix;
|
||||||
if (")".equals(suffix)) {
|
if (")".equals(suffix)) {
|
||||||
fullSuffix = "," + suffix;
|
fullSuffix = "," + suffix;
|
||||||
@ -968,7 +968,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
|||||||
} else {
|
} else {
|
||||||
return prefix + getTypeString(inner, "[", "]", referencedModelNames) + fullSuffix;
|
return prefix + getTypeString(inner, "[", "]", referencedModelNames) + fullSuffix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ModelUtils.isFileSchema(p)) {
|
if (ModelUtils.isFileSchema(p)) {
|
||||||
return prefix + "file_type" + fullSuffix;
|
return prefix + "file_type" + fullSuffix;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor;
|
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor;
|
||||||
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
|
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
|
||||||
|
import org.springframework.security.oauth2.client.OAuth2ClientContext;
|
||||||
{{#isApplication}}
|
{{#isApplication}}
|
||||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
|
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
|
||||||
{{/isApplication}}
|
{{/isApplication}}
|
||||||
@ -71,8 +72,14 @@ public class ClientConfiguration {
|
|||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() {
|
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor(OAuth2ClientContext oAuth2ClientContext) {
|
||||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails());
|
return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, {{{name}}}ResourceDetails());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
public OAuth2ClientContext oAuth2ClientContext() {
|
||||||
|
return new DefaultOAuth2ClientContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#isCode}}
|
{{#isCode}}
|
||||||
|
@ -15,5 +15,6 @@ public class {{unrealModuleName}} : ModuleRules
|
|||||||
"Json",
|
"Json",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
PCHUsage = PCHUsageMode.NoPCHs;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,7 +52,7 @@ public:
|
|||||||
{{#responses.0}}
|
{{#responses.0}}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
{{/responses.0}}
|
{{/responses.0}}
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
{{#returnType}}{{{returnType}}} Content;{{/returnType}}
|
{{#returnType}}{{{returnType}}} Content;{{/returnType}}
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Serialization/JsonSerializer.h"
|
#include "Serialization/JsonSerializer.h"
|
||||||
#include "Dom/JsonObject.h"
|
#include "Dom/JsonObject.h"
|
||||||
#include "Misc/Base64.h"
|
#include "Misc/Base64.h"
|
||||||
|
#include "PlatformHttp.h"
|
||||||
|
|
||||||
class IHttpRequest;
|
class IHttpRequest;
|
||||||
|
|
||||||
@ -196,10 +197,22 @@ inline FString CollectionToUrlString_multi(const TArray<T>& Collection, const TC
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& Value)
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const T& Value)
|
|
||||||
{
|
{
|
||||||
Writer->WriteValue(Value);
|
if (Value.IsValid())
|
||||||
|
{
|
||||||
|
FJsonSerializer::Serialize(Value.ToSharedRef(), Writer, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Writer->WriteObjectStart();
|
||||||
|
Writer->WriteObjectEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void WriteJsonValue(JsonWriter& Writer, const TArray<uint8>& Value)
|
||||||
|
{
|
||||||
|
Writer->WriteValue(ToString(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const FDateTime& Value)
|
inline void WriteJsonValue(JsonWriter& Writer, const FDateTime& Value)
|
||||||
@ -212,6 +225,12 @@ inline void WriteJsonValue(JsonWriter& Writer, const Model& Value)
|
|||||||
Value.WriteJson(Writer);
|
Value.WriteJson(Writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
||||||
|
inline void WriteJsonValue(JsonWriter& Writer, const T& Value)
|
||||||
|
{
|
||||||
|
Writer->WriteValue(Value);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TArray<T>& Value)
|
inline void WriteJsonValue(JsonWriter& Writer, const TArray<T>& Value)
|
||||||
{
|
{
|
||||||
@ -235,54 +254,8 @@ inline void WriteJsonValue(JsonWriter& Writer, const TMap<FString, T>& Value)
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& Value)
|
|
||||||
{
|
|
||||||
if (Value.IsValid())
|
|
||||||
{
|
|
||||||
FJsonSerializer::Serialize(Value.ToSharedRef(), Writer, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Writer->WriteObjectStart();
|
|
||||||
Writer->WriteObjectEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TArray<uint8>& Value)
|
|
||||||
{
|
|
||||||
Writer->WriteValue(ToString(Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, T& Value)
|
|
||||||
{
|
|
||||||
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
|
||||||
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
|
||||||
{
|
|
||||||
return TryGetJsonValue(JsonValue, Value);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, TOptional<T>& OptionalValue)
|
|
||||||
{
|
|
||||||
if(JsonObject->HasField(Key))
|
|
||||||
{
|
|
||||||
T Value;
|
|
||||||
if (TryGetJsonValue(JsonObject, Key, Value))
|
|
||||||
{
|
|
||||||
OptionalValue = Value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true; // Absence of optional value is not a parsing error
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, FString& Value)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, FString& Value)
|
||||||
{
|
{
|
||||||
FString TmpValue;
|
FString TmpValue;
|
||||||
@ -316,6 +289,34 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, bool& Value
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TSharedPtr<FJsonObject>& JsonObjectValue)
|
||||||
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (JsonValue->TryGetObject(Object))
|
||||||
|
{
|
||||||
|
JsonObjectValue = *Object;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<uint8>& Value)
|
||||||
|
{
|
||||||
|
FString TmpValue;
|
||||||
|
if (JsonValue->TryGetString(TmpValue))
|
||||||
|
{
|
||||||
|
Base64UrlDecode(TmpValue, Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, Model& Value)
|
||||||
|
{
|
||||||
|
return Value.FromJson(JsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||||
{
|
{
|
||||||
@ -329,15 +330,6 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, Model& Value)
|
|
||||||
{
|
|
||||||
const TSharedPtr<FJsonObject>* Object;
|
|
||||||
if (JsonValue->TryGetObject(Object))
|
|
||||||
return Value.FromJson(*Object);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<T>& ArrayValue)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<T>& ArrayValue)
|
||||||
{
|
{
|
||||||
@ -377,27 +369,32 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TMap<FStrin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TSharedPtr<FJsonObject>& JsonObjectValue)
|
template<typename T>
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, T& Value)
|
||||||
{
|
{
|
||||||
const TSharedPtr<FJsonObject>* Object;
|
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
||||||
if (JsonValue->TryGetObject(Object))
|
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
||||||
{
|
{
|
||||||
JsonObjectValue = *Object;
|
return TryGetJsonValue(JsonValue, Value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<uint8>& Value)
|
template<typename T>
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, TOptional<T>& OptionalValue)
|
||||||
{
|
{
|
||||||
FString TmpValue;
|
if(JsonObject->HasField(Key))
|
||||||
if (JsonValue->TryGetString(TmpValue))
|
|
||||||
{
|
{
|
||||||
Base64UrlDecode(TmpValue, Value);
|
T Value;
|
||||||
return true;
|
if (TryGetJsonValue(JsonObject, Key, Value))
|
||||||
|
{
|
||||||
|
OptionalValue = Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
return true; // Absence of optional value is not a parsing error
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Interfaces/IHttpRequest.h"
|
#include "Interfaces/IHttpRequest.h"
|
||||||
#include "PlatformHttp.h"
|
#include "PlatformHttp.h"
|
||||||
#include "Misc/FileHelper.h"
|
#include "Misc/FileHelper.h"
|
||||||
|
#include "Misc/Paths.h"
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}}
|
namespace {{this}}
|
||||||
|
@ -18,7 +18,7 @@ class {{dllapi}} Model
|
|||||||
public:
|
public:
|
||||||
virtual ~Model() {}
|
virtual ~Model() {}
|
||||||
virtual void WriteJson(JsonWriter& Writer) const = 0;
|
virtual void WriteJson(JsonWriter& Writer) const = 0;
|
||||||
virtual bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) = 0;
|
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class {{dllapi}} Request
|
class {{dllapi}} Request
|
||||||
@ -33,7 +33,7 @@ class {{dllapi}} Response
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Response() {}
|
virtual ~Response() {}
|
||||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) = 0;
|
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||||
|
|
||||||
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
||||||
bool IsSuccessful() const { return Successful; }
|
bool IsSuccessful() const { return Successful; }
|
||||||
|
@ -21,9 +21,26 @@ class {{dllapi}} {{classname}} : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~{{classname}}() {}
|
virtual ~{{classname}}() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
|
{{#isString}}
|
||||||
|
{{#isEnum}}
|
||||||
|
{{#allowableValues}}
|
||||||
|
enum class Values
|
||||||
|
{
|
||||||
|
{{#enumVars}}
|
||||||
|
{{name}},
|
||||||
|
{{/enumVars}}
|
||||||
|
};
|
||||||
|
|
||||||
|
Values Value{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
|
||||||
|
{{/allowableValues}}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{^isEnum}}
|
||||||
|
FString Value{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/isString}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
|
@ -11,6 +11,54 @@ namespace {{this}}
|
|||||||
{
|
{
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
|
{{#isEnum}}
|
||||||
|
inline FString ToString(const {{classname}}::Values& Value)
|
||||||
|
{
|
||||||
|
{{#allowableValues}}
|
||||||
|
switch (Value)
|
||||||
|
{
|
||||||
|
{{#enumVars}}
|
||||||
|
case {{classname}}::Values::{{name}}:
|
||||||
|
return TEXT({{{value}}});
|
||||||
|
{{/enumVars}}
|
||||||
|
}
|
||||||
|
{{/allowableValues}}
|
||||||
|
|
||||||
|
UE_LOG(Log{{unrealModuleName}}, Error, TEXT("Invalid {{classname}}::Values Value (%d)"), (int)Value);
|
||||||
|
return TEXT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FStringFormatArg ToStringFormatArg(const {{classname}}::Values& Value)
|
||||||
|
{
|
||||||
|
return FStringFormatArg(ToString(Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void WriteJsonValue(JsonWriter& Writer, const {{classname}}::Values& Value)
|
||||||
|
{
|
||||||
|
WriteJsonValue(Writer, ToString(Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, {{classname}}::Values& Value)
|
||||||
|
{
|
||||||
|
{{#allowableValues}}
|
||||||
|
FString TmpValue;
|
||||||
|
if (JsonValue->TryGetString(TmpValue))
|
||||||
|
{
|
||||||
|
static TMap<FString, {{classname}}::Values> StringToEnum = { {{#enumVars}}
|
||||||
|
{ TEXT({{{value}}}), {{classname}}::Values::{{name}} },{{/enumVars}} };
|
||||||
|
|
||||||
|
const auto Found = StringToEnum.Find(TmpValue);
|
||||||
|
if(Found)
|
||||||
|
{
|
||||||
|
Value = *Found;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/allowableValues}}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isEnum}}
|
||||||
{{#hasEnums}}
|
{{#hasEnums}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
@ -65,9 +113,10 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, {{classname
|
|||||||
{{/hasEnums}}
|
{{/hasEnums}}
|
||||||
void {{classname}}::WriteJson(JsonWriter& Writer) const
|
void {{classname}}::WriteJson(JsonWriter& Writer) const
|
||||||
{
|
{
|
||||||
{{#parent}}
|
{{#isString}}
|
||||||
#error inheritance not handled right now
|
WriteJsonValue(Writer, Value);
|
||||||
{{/parent}}
|
{{/isString}}
|
||||||
|
{{^isString}}
|
||||||
Writer->WriteObjectStart();
|
Writer->WriteObjectStart();
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
@ -81,18 +130,29 @@ void {{classname}}::WriteJson(JsonWriter& Writer) const
|
|||||||
{{/required}}
|
{{/required}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
|
{{/isString}}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool {{classname}}::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool {{classname}}::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
{{#isString}}
|
||||||
|
return TryGetJsonValue(JsonValue, Value);
|
||||||
|
{{/isString}}
|
||||||
|
{{^isString}}
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("{{baseName}}"), {{name}});
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("{{baseName}}"), {{name}});
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
|
{{/isString}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -15,6 +15,35 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
|
{{#discriminator}}
|
||||||
|
{{#mappedModels}}
|
||||||
|
{{#-first}}
|
||||||
|
// use discriminator value to speed up the lookup
|
||||||
|
var jsonDict map[string]interface{}
|
||||||
|
err := json.Unmarshal(data, &jsonDict)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/-first}}
|
||||||
|
// check if the discriminator value is '{{{mappingName}}}'
|
||||||
|
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
|
||||||
|
// try to unmarshal JSON data into {{{modelName}}}
|
||||||
|
err = json.Unmarshal(data, &dst.{{{modelName}}});
|
||||||
|
if err == nil {
|
||||||
|
json{{{modelName}}}, _ := json.Marshal(dst.{{{modelName}}})
|
||||||
|
if string(json{{{modelName}}}) == "{}" { // empty struct
|
||||||
|
dst.{{{modelName}}} = nil
|
||||||
|
} else {
|
||||||
|
return nil // data stored in dst.{{{modelName}}}, return on the first match
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dst.{{{modelName}}} = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/mappedModels}}
|
||||||
|
{{/discriminator}}
|
||||||
{{#anyOf}}
|
{{#anyOf}}
|
||||||
// try to unmarshal JSON data into {{{.}}}
|
// try to unmarshal JSON data into {{{.}}}
|
||||||
err = json.Unmarshal(data, &dst.{{{.}}});
|
err = json.Unmarshal(data, &dst.{{{.}}});
|
||||||
@ -44,4 +73,4 @@ func (src *{{classname}}) MarshalJSON() ([]byte, error) {
|
|||||||
return nil, nil // no data in anyOf schemas
|
return nil, nil // no data in anyOf schemas
|
||||||
}
|
}
|
||||||
|
|
||||||
{{>nullable_model}}
|
{{>nullable_model}}
|
||||||
|
@ -24,9 +24,40 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
|
{{#useOneOfDiscriminatorLookup}}
|
||||||
|
{{#discriminator}}
|
||||||
|
{{#mappedModels}}
|
||||||
|
{{#-first}}
|
||||||
|
// use discriminator value to speed up the lookup
|
||||||
|
var jsonDict map[string]interface{}
|
||||||
|
err = json.Unmarshal(data, &jsonDict)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/-first}}
|
||||||
|
// check if the discriminator value is '{{{mappingName}}}'
|
||||||
|
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
|
||||||
|
// try to unmarshal JSON data into {{{modelName}}}
|
||||||
|
err = json.Unmarshal(data, &dst.{{{modelName}}})
|
||||||
|
if err == nil {
|
||||||
|
json{{{modelName}}}, _ := json.Marshal(dst.{{{modelName}}})
|
||||||
|
if string(json{{{modelName}}}) == "{}" { // empty struct
|
||||||
|
dst.{{{modelName}}} = nil
|
||||||
|
} else {
|
||||||
|
return nil // data stored in dst.{{{modelName}}}, return on the first match
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dst.{{{modelName}}} = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/mappedModels}}
|
||||||
|
{{/discriminator}}
|
||||||
|
{{/useOneOfDiscriminatorLookup}}
|
||||||
{{#oneOf}}
|
{{#oneOf}}
|
||||||
// try to unmarshal data into {{{.}}}
|
// try to unmarshal data into {{{.}}}
|
||||||
err = json.Unmarshal(data, &dst.{{{.}}});
|
err = json.Unmarshal(data, &dst.{{{.}}})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
json{{{.}}}, _ := json.Marshal(dst.{{{.}}})
|
json{{{.}}}, _ := json.Marshal(dst.{{{.}}})
|
||||||
if string(json{{{.}}}) == "{}" { // empty struct
|
if string(json{{{.}}}) == "{}" { // empty struct
|
||||||
@ -76,4 +107,4 @@ func (obj *{{classname}}) GetActualInstance() (interface{}) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
{{>nullable_model}}
|
{{>nullable_model}}
|
||||||
|
@ -13,8 +13,15 @@ type {{classname}} struct {
|
|||||||
{{/description}}
|
{{/description}}
|
||||||
{{name}} {{^required}}{{^isNullable}}*{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
|
{{name}} {{^required}}{{^isNullable}}*{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
AdditionalProperties map[string]interface{}
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
type _{{{classname}}} {{{classname}}}
|
||||||
|
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
// New{{classname}} instantiates a new {{classname}} object
|
// New{{classname}} instantiates a new {{classname}} object
|
||||||
// This constructor will assign default values to properties that have it defined,
|
// This constructor will assign default values to properties that have it defined,
|
||||||
// and makes sure properties required by API are set, but the set of arguments
|
// and makes sure properties required by API are set, but the set of arguments
|
||||||
@ -246,7 +253,35 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
|
||||||
|
for key, value := range o.AdditionalProperties {
|
||||||
|
toSerialize[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
return json.Marshal(toSerialize)
|
return json.Marshal(toSerialize)
|
||||||
}
|
}
|
||||||
|
|
||||||
{{>nullable_model}}
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
|
||||||
|
var{{{classname}}} := _{{{classname}}}{}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil {
|
||||||
|
*o = {{{classname}}}(var{{{classname}}})
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalProperties := make(map[string]interface{})
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||||
|
{{#vars}}
|
||||||
|
delete(additionalProperties, "{{{baseName}}}")
|
||||||
|
{{/vars}}
|
||||||
|
o.AdditionalProperties = additionalProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
|
{{>nullable_model}}
|
||||||
|
@ -48,9 +48,9 @@ import java.io.Serializable
|
|||||||
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#vendorExtensions.x-has-data-class-body}} {
|
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMapModel}}(){{/isMapModel}}{{#isArrayModel}}(){{/isArrayModel}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#vendorExtensions.x-has-data-class-body}} {
|
||||||
{{/vendorExtensions.x-has-data-class-body}}
|
{{/vendorExtensions.x-has-data-class-body}}
|
||||||
{{#serializableModel}}
|
{{#serializableModel}}
|
||||||
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
private const val serialVersionUID: Long = 123
|
private const val serialVersionUID: Long = 123
|
||||||
}
|
}
|
||||||
{{/serializableModel}}
|
{{/serializableModel}}
|
||||||
{{#discriminator}}{{#vars}}{{#required}}
|
{{#discriminator}}{{#vars}}{{#required}}
|
||||||
{{>interface_req_var}}{{/required}}{{^required}}
|
{{>interface_req_var}}{{/required}}{{^required}}
|
||||||
|
@ -47,11 +47,11 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
|||||||
|
|
||||||
{{/enumVars}}{{/allowableValues}}
|
{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This override toString avoids using the enum var name and uses the actual api value instead.
|
This override toString avoids using the enum var name and uses the actual api value instead.
|
||||||
In cases the var name and value are different, the client would send incorrect enums to the server.
|
In cases the var name and value are different, the client would send incorrect enums to the server.
|
||||||
**/
|
**/
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return value{{^isString}}.toString(){{/isString}}
|
return value{{^isString}}.toString(){{/isString}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{/swaggerAnnotations}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{paramName}}: {{>optionalDataType}}{{/isQueryParam}}
|
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{/swaggerAnnotations}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}) {{paramName}}: {{>optionalDataType}}{{/isQueryParam}}
|
@ -5,8 +5,8 @@ Describe -tag '{{{packageName}}}' -name '{{{apiNamePrefix}}}{{{classname}}}' {
|
|||||||
Context '{{{vendorExtensions.x-powershell-method-name}}}' {
|
Context '{{{vendorExtensions.x-powershell-method-name}}}' {
|
||||||
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
|
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
|
||||||
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
||||||
#$TestResult | Should BeOfType TODO
|
#$TestResult | Should -BeOfType TODO
|
||||||
#$TestResult.property | Should Be 0
|
#$TestResult.property | Should -Be 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,35 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
|
{{#discriminator}}
|
||||||
|
{{#mappedModels}}
|
||||||
|
{{#-first}}
|
||||||
|
$JsonData = ConvertFrom-Json -InputObject $Json
|
||||||
|
{{/-first}}
|
||||||
|
# check if the discriminator value is '{{{mappingName}}}'
|
||||||
|
if ($JsonData.PSobject.Properties["{{{propertyBaseName}}}"].value -eq "{{{mappingName}}}") {
|
||||||
|
# try to match {{{modelName}}} defined in the anyOf schemas
|
||||||
|
try {
|
||||||
|
$matchInstance = ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{modelName}}} $Json
|
||||||
|
|
||||||
|
foreach($property in $matchInstance.PsObject.Properties) {
|
||||||
|
if ($null -ne $property.Value) {
|
||||||
|
$matchType = "{{{modelName}}}"
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
"ActualType" = ${matchType}
|
||||||
|
"ActualInstance" = ${matchInstance}
|
||||||
|
"anyOfSchemas" = @({{#anyOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/anyOf}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
# fail to match the schema defined in anyOf with the discriminator lookup, proceed to the next one
|
||||||
|
Write-Debug "Failed to match '{{{modelName}}}' defined in anyOf ({{{apiNamePrefix}}}{{{classname}}}) using the discriminator lookup ({{{mappingName}}}). Proceeding with the typical anyOf type matching."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/mappedModels}}
|
||||||
|
{{/discriminator}}
|
||||||
{{#anyOf}}
|
{{#anyOf}}
|
||||||
if ($match -ne 0) { # no match yet
|
if ($match -ne 0) { # no match yet
|
||||||
# try to match {{{.}}} defined in the anyOf schemas
|
# try to match {{{.}}} defined in the anyOf schemas
|
||||||
|
@ -38,6 +38,37 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
|
{{#useOneOfDiscriminatorLookup}}
|
||||||
|
{{#discriminator}}
|
||||||
|
{{#mappedModels}}
|
||||||
|
{{#-first}}
|
||||||
|
$JsonData = ConvertFrom-Json -InputObject $Json
|
||||||
|
{{/-first}}
|
||||||
|
# check if the discriminator value is '{{{mappingName}}}'
|
||||||
|
if ($JsonData.PSobject.Properties["{{{propertyBaseName}}}"].value -eq "{{{mappingName}}}") {
|
||||||
|
# try to match {{{modelName}}} defined in the oneOf schemas
|
||||||
|
try {
|
||||||
|
$matchInstance = ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{modelName}}} $Json
|
||||||
|
|
||||||
|
foreach($property in $matchInstance.PsObject.Properties) {
|
||||||
|
if ($null -ne $property.Value) {
|
||||||
|
$matchType = "{{{modelName}}}"
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
"ActualType" = ${matchType}
|
||||||
|
"ActualInstance" = ${matchInstance}
|
||||||
|
"oneOfSchemas" = @({{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
# fail to match the schema defined in oneOf with the discriminator lookup, proceed to the next one
|
||||||
|
Write-Debug "Failed to match '{{{modelName}}}' defined in oneOf ({{{apiNamePrefix}}}{{{classname}}}) using the discriminator lookup ({{{mappingName}}}). Proceeding with the typical oneOf type matching."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/mappedModels}}
|
||||||
|
{{/discriminator}}
|
||||||
|
{{/useOneOfDiscriminatorLookup}}
|
||||||
{{#oneOf}}
|
{{#oneOf}}
|
||||||
# try to match {{{.}}} defined in the oneOf schemas
|
# try to match {{{.}}} defined in the oneOf schemas
|
||||||
try {
|
try {
|
||||||
|
@ -129,13 +129,24 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
|||||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
|
||||||
$JsonParameters = ConvertFrom-Json -InputObject $Json
|
$JsonParameters = ConvertFrom-Json -InputObject $Json
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties = @{}
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
|
|
||||||
# check if Json contains properties not defined in {{{apiNamePrefix}}}{{{classname}}}
|
# check if Json contains properties not defined in {{{apiNamePrefix}}}{{{classname}}}
|
||||||
$AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}})
|
$AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}})
|
||||||
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
|
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
|
||||||
|
{{^vendorExtensions.x-additional-properties}}
|
||||||
if (!($AllProperties.Contains($name))) {
|
if (!($AllProperties.Contains($name))) {
|
||||||
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
|
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
|
||||||
}
|
}
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
# store undefined properties in additionalProperties
|
||||||
|
if (!($AllProperties.Contains($name))) {
|
||||||
|
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
|
||||||
|
}
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#requiredVars}}
|
{{#requiredVars}}
|
||||||
@ -166,6 +177,9 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
|||||||
"<<baseName>>" = ${<<name>>}
|
"<<baseName>>" = ${<<name>>}
|
||||||
<</allVars>>
|
<</allVars>>
|
||||||
<<={{ }}=>>
|
<<={{ }}=>>
|
||||||
|
{{#vendorExtensions.x-additional-properties}}
|
||||||
|
"AdditionalProperties" = ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties
|
||||||
|
{{/vendorExtensions.x-additional-properties}}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $PSO
|
return $PSO
|
||||||
|
@ -6,8 +6,8 @@ Describe -tag '{{{packageName}}}' -name '{{{apiNamePrefix}}}{{{classname}}}' {
|
|||||||
It 'Initialize-{{{apiNamePrefix}}}{{{classname}}}' {
|
It 'Initialize-{{{apiNamePrefix}}}{{{classname}}}' {
|
||||||
# a simple test to create an object
|
# a simple test to create an object
|
||||||
#$NewObject = Initialize-{{{apiNamePrefix}}}{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
|
#$NewObject = Initialize-{{{apiNamePrefix}}}{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
|
||||||
#$NewObject | Should BeOfType {{classname}}
|
#$NewObject | Should -BeOfType {{classname}}
|
||||||
#$NewObject.property | Should Be 0
|
#$NewObject.property | Should -Be 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ class {{classname}}(object):
|
|||||||
{{/notes}}
|
{{/notes}}
|
||||||
This method makes a synchronous HTTP request by default. To make an
|
This method makes a synchronous HTTP request by default. To make an
|
||||||
asynchronous HTTP request, please pass async_req=True
|
asynchronous HTTP request, please pass async_req=True
|
||||||
|
|
||||||
{{#sortParamsByRequiredFlag}}
|
{{#sortParamsByRequiredFlag}}
|
||||||
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
||||||
{{/sortParamsByRequiredFlag}}
|
{{/sortParamsByRequiredFlag}}
|
||||||
@ -46,20 +47,24 @@ class {{classname}}(object):
|
|||||||
{{/sortParamsByRequiredFlag}}
|
{{/sortParamsByRequiredFlag}}
|
||||||
>>> result = thread.get()
|
>>> result = thread.get()
|
||||||
|
|
||||||
:param async_req bool: execute request asynchronously
|
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
|
:param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
|
||||||
|
:type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
:param async_req: Whether to execute the request asynchronously.
|
||||||
|
:type async_req: bool, optional
|
||||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||||
be returned without reading/decoding response
|
be returned without reading/decoding response
|
||||||
data. Default is True.
|
data. Default is True.
|
||||||
|
:type _preload_content: bool, optional
|
||||||
:param _request_timeout: timeout setting for this request. If one
|
:param _request_timeout: timeout setting for this request. If one
|
||||||
number provided, it will be total request
|
number provided, it will be total request
|
||||||
timeout. It can also be a pair (tuple) of
|
timeout. It can also be a pair (tuple) of
|
||||||
(connection, read) timeouts.
|
(connection, read) timeouts.
|
||||||
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
:return: Returns the result object.
|
||||||
If the method is called asynchronously,
|
If the method is called asynchronously,
|
||||||
returns the request thread.
|
returns the request thread.
|
||||||
|
:rtype: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||||
"""
|
"""
|
||||||
kwargs['_return_http_data_only'] = True
|
kwargs['_return_http_data_only'] = True
|
||||||
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
|
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
|
||||||
@ -72,6 +77,7 @@ class {{classname}}(object):
|
|||||||
{{/notes}}
|
{{/notes}}
|
||||||
This method makes a synchronous HTTP request by default. To make an
|
This method makes a synchronous HTTP request by default. To make an
|
||||||
asynchronous HTTP request, please pass async_req=True
|
asynchronous HTTP request, please pass async_req=True
|
||||||
|
|
||||||
{{#sortParamsByRequiredFlag}}
|
{{#sortParamsByRequiredFlag}}
|
||||||
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
||||||
{{/sortParamsByRequiredFlag}}
|
{{/sortParamsByRequiredFlag}}
|
||||||
@ -80,22 +86,27 @@ class {{classname}}(object):
|
|||||||
{{/sortParamsByRequiredFlag}}
|
{{/sortParamsByRequiredFlag}}
|
||||||
>>> result = thread.get()
|
>>> result = thread.get()
|
||||||
|
|
||||||
:param async_req bool: execute request asynchronously
|
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}}
|
:param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
|
||||||
|
:type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
:param async_req: Whether to execute the request asynchronously.
|
||||||
|
:type async_req: bool, optional
|
||||||
:param _return_http_data_only: response data without head status code
|
:param _return_http_data_only: response data without head status code
|
||||||
and headers
|
and headers
|
||||||
|
:type _return_http_data_only: bool, optional
|
||||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||||
be returned without reading/decoding response
|
be returned without reading/decoding response
|
||||||
data. Default is True.
|
data. Default is True.
|
||||||
|
:type _preload_content: bool, optional
|
||||||
:param _request_timeout: timeout setting for this request. If one
|
:param _request_timeout: timeout setting for this request. If one
|
||||||
number provided, it will be total request
|
number provided, it will be total request
|
||||||
timeout. It can also be a pair (tuple) of
|
timeout. It can also be a pair (tuple) of
|
||||||
(connection, read) timeouts.
|
(connection, read) timeouts.
|
||||||
:return: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
|
:return: Returns the result object.
|
||||||
If the method is called asynchronously,
|
If the method is called asynchronously,
|
||||||
returns the request thread.
|
returns the request thread.
|
||||||
|
:rtype: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
{{#servers.0}}
|
{{#servers.0}}
|
||||||
|
@ -107,7 +107,7 @@ class {{classname}}(object):
|
|||||||
{{/description}}
|
{{/description}}
|
||||||
|
|
||||||
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
||||||
:type: {{dataType}}
|
:type {{name}}: {{dataType}}
|
||||||
"""
|
"""
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
|
@ -66,6 +66,7 @@ class {{classname}}(object):
|
|||||||
{{/notes}}
|
{{/notes}}
|
||||||
This method makes a synchronous HTTP request by default. To make an
|
This method makes a synchronous HTTP request by default. To make an
|
||||||
asynchronous HTTP request, please pass async_req=True
|
asynchronous HTTP request, please pass async_req=True
|
||||||
|
|
||||||
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
|
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
|
||||||
>>> result = thread.get()
|
>>> result = thread.get()
|
||||||
|
|
||||||
|
@ -291,6 +291,7 @@ class ApiClient(object):
|
|||||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||||
:param _check_type: boolean, whether to check the types of the data
|
:param _check_type: boolean, whether to check the types of the data
|
||||||
received from the server
|
received from the server
|
||||||
|
:type _check_type: bool
|
||||||
|
|
||||||
:return: deserialized object.
|
:return: deserialized object.
|
||||||
"""
|
"""
|
||||||
@ -350,22 +351,28 @@ class ApiClient(object):
|
|||||||
(float, none_type)
|
(float, none_type)
|
||||||
([int, none_type],)
|
([int, none_type],)
|
||||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||||
:param files dict: key -> field name, value -> a list of open file
|
:param files: key -> field name, value -> a list of open file
|
||||||
objects for `multipart/form-data`.
|
objects for `multipart/form-data`.
|
||||||
|
:type files: dict
|
||||||
:param async_req bool: execute request asynchronously
|
:param async_req bool: execute request asynchronously
|
||||||
|
:type async_req: bool, optional
|
||||||
:param _return_http_data_only: response data without head status code
|
:param _return_http_data_only: response data without head status code
|
||||||
and headers
|
and headers
|
||||||
|
:type _return_http_data_only: bool, optional
|
||||||
:param collection_formats: dict of collection formats for path, query,
|
:param collection_formats: dict of collection formats for path, query,
|
||||||
header, and post parameters.
|
header, and post parameters.
|
||||||
|
:type collection_formats: dict, optional
|
||||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||||
be returned without reading/decoding response
|
be returned without reading/decoding response
|
||||||
data. Default is True.
|
data. Default is True.
|
||||||
|
:type _preload_content: bool, optional
|
||||||
:param _request_timeout: timeout setting for this request. If one
|
:param _request_timeout: timeout setting for this request. If one
|
||||||
number provided, it will be total request
|
number provided, it will be total request
|
||||||
timeout. It can also be a pair (tuple) of
|
timeout. It can also be a pair (tuple) of
|
||||||
(connection, read) timeouts.
|
(connection, read) timeouts.
|
||||||
:param _check_type: boolean describing if the data back from the server
|
:param _check_type: boolean describing if the data back from the server
|
||||||
should have its type checked.
|
should have its type checked.
|
||||||
|
:type _check_type: bool, optional
|
||||||
:return:
|
:return:
|
||||||
If async_req parameter is True,
|
If async_req parameter is True,
|
||||||
the request will be called asynchronously.
|
the request will be called asynchronously.
|
||||||
@ -559,9 +566,9 @@ class ApiClient(object):
|
|||||||
:param headers: Header parameters dict to be updated.
|
:param headers: Header parameters dict to be updated.
|
||||||
:param querys: Query parameters tuple list to be updated.
|
:param querys: Query parameters tuple list to be updated.
|
||||||
:param auth_settings: Authentication setting identifiers list.
|
:param auth_settings: Authentication setting identifiers list.
|
||||||
:resource_path: A string representation of the HTTP request resource path.
|
:param resource_path: A string representation of the HTTP request resource path.
|
||||||
:method: A string representation of the HTTP request method.
|
:param method: A string representation of the HTTP request method.
|
||||||
:body: A object representing the body of the HTTP request.
|
:param body: A object representing the body of the HTTP request.
|
||||||
The object type is the return value of sanitize_for_serialization().
|
The object type is the return value of sanitize_for_serialization().
|
||||||
"""
|
"""
|
||||||
if not auth_settings:
|
if not auth_settings:
|
||||||
|
@ -37,7 +37,12 @@ from {{packageName}}.model_utils import ( # noqa: F401
|
|||||||
{{> python-experimental/model_templates/model_simple }}
|
{{> python-experimental/model_templates/model_simple }}
|
||||||
{{/isAlias}}
|
{{/isAlias}}
|
||||||
{{^isAlias}}
|
{{^isAlias}}
|
||||||
|
{{#isArrayModel}}
|
||||||
|
{{> python-experimental/model_templates/model_simple }}
|
||||||
|
{{/isArrayModel}}
|
||||||
|
{{^isArrayModel}}
|
||||||
{{> python-experimental/model_templates/model_normal }}
|
{{> python-experimental/model_templates/model_normal }}
|
||||||
|
{{/isArrayModel}}
|
||||||
{{/isAlias}}
|
{{/isAlias}}
|
||||||
{{/interfaces}}
|
{{/interfaces}}
|
||||||
{{#interfaces}}
|
{{#interfaces}}
|
||||||
|
@ -41,7 +41,7 @@ export class {{classname}} extends BaseAPI {
|
|||||||
{{#hasParams}}
|
{{#hasParams}}
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
throwIfNullOrUndefined({{> paramNamePartial}}, '{{nickname}}');
|
throwIfNullOrUndefined({{> paramNamePartial}}, '{{> paramNamePartial}}', '{{nickname}}');
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
|
@ -178,9 +178,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +21,10 @@ import io.swagger.v3.oas.models.OpenAPI;
|
|||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
||||||
import io.swagger.v3.oas.models.media.*;
|
import io.swagger.v3.oas.models.media.*;
|
||||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
|
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
|
||||||
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -268,7 +270,7 @@ public class PythonClientExperimentalTest {
|
|||||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||||
Assert.assertEquals(cm.classVarName, "sample");
|
Assert.assertEquals(cm.classVarName, "sample");
|
||||||
Assert.assertEquals(cm.description, "an array model");
|
Assert.assertEquals(cm.description, "an array model");
|
||||||
Assert.assertEquals(cm.vars.size(), 0);
|
Assert.assertEquals(cm.vars.size(), 1); // there is one value for Childer definition
|
||||||
Assert.assertEquals(cm.parent, "list");
|
Assert.assertEquals(cm.parent, "list");
|
||||||
Assert.assertEquals(cm.imports.size(), 1);
|
Assert.assertEquals(cm.imports.size(), 1);
|
||||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1);
|
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1);
|
||||||
@ -293,4 +295,14 @@ public class PythonClientExperimentalTest {
|
|||||||
Assert.assertEquals(cm.imports.size(), 0);
|
Assert.assertEquals(cm.imports.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(description = "parse date and date-time example value")
|
||||||
|
public void parseDateAndDateTimeExamplesTest() {
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml");
|
||||||
|
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||||
|
|
||||||
|
Schema modelSchema = ModelUtils.getSchema(openAPI, "DateTimeTest");
|
||||||
|
String defaultValue = codegen.toDefaultValue(modelSchema);
|
||||||
|
Assert.assertEquals(defaultValue, "dateutil_parser('2010-01-01T10:10:10.000111+01:00')");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1810,6 +1810,7 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
banana:
|
banana:
|
||||||
type: object
|
type: object
|
||||||
|
additionalProperties: true
|
||||||
properties:
|
properties:
|
||||||
lengthCm:
|
lengthCm:
|
||||||
type: number
|
type: number
|
||||||
|
@ -699,6 +699,7 @@ components:
|
|||||||
xml:
|
xml:
|
||||||
name: User
|
name: User
|
||||||
Tag:
|
Tag:
|
||||||
|
additionalProperties: true
|
||||||
title: Pet Tag
|
title: Pet Tag
|
||||||
description: A tag for a pet
|
description: A tag for a pet
|
||||||
type: object
|
type: object
|
||||||
|
@ -758,6 +758,8 @@ paths:
|
|||||||
description: None
|
description: None
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
default: '2010-02-01T10:20:10.11111+01:00'
|
||||||
|
example: '2020-02-02T20:20:20.22222Z'
|
||||||
password:
|
password:
|
||||||
description: None
|
description: None
|
||||||
type: string
|
type: string
|
||||||
@ -1097,6 +1099,19 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/HealthCheckResult'
|
$ref: '#/components/schemas/HealthCheckResult'
|
||||||
|
/fake/array-of-enums:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- fake
|
||||||
|
summary: Array of Enums
|
||||||
|
operationId: getArrayOfEnums
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Got named array of enums
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ArrayOfEnums'
|
||||||
servers:
|
servers:
|
||||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||||
description: petstore server
|
description: petstore server
|
||||||
@ -1202,6 +1217,7 @@ components:
|
|||||||
shipDate:
|
shipDate:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
example: '2020-02-02T20:20:20.000222Z'
|
||||||
status:
|
status:
|
||||||
type: string
|
type: string
|
||||||
description: Order Status
|
description: Order Status
|
||||||
@ -1443,7 +1459,7 @@ components:
|
|||||||
maximum: 543.2
|
maximum: 543.2
|
||||||
minimum: 32.1
|
minimum: 32.1
|
||||||
type: number
|
type: number
|
||||||
multipleOf: 32.5
|
multipleOf: 32.5
|
||||||
float:
|
float:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: float
|
||||||
@ -1466,9 +1482,11 @@ components:
|
|||||||
date:
|
date:
|
||||||
type: string
|
type: string
|
||||||
format: date
|
format: date
|
||||||
|
example: '2020-02-02'
|
||||||
dateTime:
|
dateTime:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
example: '2007-12-03T10:15:30+01:00'
|
||||||
uuid:
|
uuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
@ -1969,7 +1987,7 @@ components:
|
|||||||
# Here the additional properties are specified using a referenced schema.
|
# Here the additional properties are specified using a referenced schema.
|
||||||
# This is just to validate the generated code works when using $ref
|
# This is just to validate the generated code works when using $ref
|
||||||
# under 'additionalProperties'.
|
# under 'additionalProperties'.
|
||||||
$ref: '#/components/schemas/fruit'
|
$ref: '#/components/schemas/fruit'
|
||||||
Shape:
|
Shape:
|
||||||
oneOf:
|
oneOf:
|
||||||
- $ref: '#/components/schemas/Triangle'
|
- $ref: '#/components/schemas/Triangle'
|
||||||
@ -2069,3 +2087,12 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
ArrayOfEnums:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/OuterEnum'
|
||||||
|
DateTimeTest:
|
||||||
|
type: string
|
||||||
|
default: '2010-01-01T10:10:10.000111+01:00'
|
||||||
|
example: '2010-01-01T10:10:10.000111+01:00'
|
||||||
|
format: date-time
|
||||||
|
2
pom.xml
2
pom.xml
@ -1294,7 +1294,7 @@
|
|||||||
<module>samples/client/petstore/java/feign10x</module>
|
<module>samples/client/petstore/java/feign10x</module>
|
||||||
<module>samples/client/petstore/java/jersey1</module>
|
<module>samples/client/petstore/java/jersey1</module>
|
||||||
<module>samples/client/petstore/java/jersey2-java8</module>
|
<module>samples/client/petstore/java/jersey2-java8</module>
|
||||||
<module>samples/openapi3/client/petstore/java/jersey2-java8</module>
|
<!--<module>samples/openapi3/client/petstore/java/jersey2-java8</module>-->
|
||||||
<module>samples/client/petstore/java/okhttp-gson</module>
|
<module>samples/client/petstore/java/okhttp-gson</module>
|
||||||
<module>samples/client/petstore/java/retrofit2</module>
|
<module>samples/client/petstore/java/retrofit2</module>
|
||||||
<module>samples/client/petstore/java/retrofit2rx</module>
|
<module>samples/client/petstore/java/retrofit2rx</module>
|
||||||
|
@ -26,5 +26,6 @@ public class OpenAPI : ModuleRules
|
|||||||
"Json",
|
"Json",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
PCHUsage = PCHUsageMode.NoPCHs;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,14 +38,19 @@ void OpenAPIApiResponse::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPIApiResponse::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPIApiResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("code"), Code);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("code"), Code);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("type"), Type);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("type"), Type);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("message"), Message);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("message"), Message);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,18 @@ void OpenAPICategory::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPICategory::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPICategory::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "Interfaces/IHttpRequest.h"
|
#include "Interfaces/IHttpRequest.h"
|
||||||
#include "PlatformHttp.h"
|
#include "PlatformHttp.h"
|
||||||
#include "Misc/FileHelper.h"
|
#include "Misc/FileHelper.h"
|
||||||
|
#include "Misc/Paths.h"
|
||||||
|
|
||||||
namespace OpenAPI
|
namespace OpenAPI
|
||||||
{
|
{
|
||||||
|
@ -96,17 +96,22 @@ void OpenAPIOrder::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPIOrder::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPIOrder::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("petId"), PetId);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("petId"), PetId);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("quantity"), Quantity);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("quantity"), Quantity);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("shipDate"), ShipDate);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("shipDate"), ShipDate);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("status"), Status);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("status"), Status);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("complete"), Complete);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("complete"), Complete);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,17 +90,22 @@ void OpenAPIPet::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPIPet::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPIPet::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("category"), Category);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("category"), Category);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("photoUrls"), PhotoUrls);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("photoUrls"), PhotoUrls);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("tags"), Tags);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("tags"), Tags);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("status"), Status);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("status"), Status);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,18 @@ void OpenAPITag::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPITag::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPITag::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,19 +58,24 @@ void OpenAPIUser::WriteJson(JsonWriter& Writer) const
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAPIUser::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
bool OpenAPIUser::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
|
||||||
{
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (!JsonValue->TryGetObject(Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ParseSuccess = true;
|
bool ParseSuccess = true;
|
||||||
|
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("username"), Username);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("username"), Username);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("firstName"), FirstName);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("firstName"), FirstName);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("lastName"), LastName);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("lastName"), LastName);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("email"), Email);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("email"), Email);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("password"), Password);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("password"), Password);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("phone"), Phone);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("phone"), Phone);
|
||||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("userStatus"), UserStatus);
|
ParseSuccess &= TryGetJsonValue(*Object, TEXT("userStatus"), UserStatus);
|
||||||
|
|
||||||
return ParseSuccess;
|
return ParseSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIApiResponse : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPIApiResponse() {}
|
virtual ~OpenAPIApiResponse() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int32> Code;
|
TOptional<int32> Code;
|
||||||
|
@ -27,7 +27,7 @@ class OPENAPI_API Model
|
|||||||
public:
|
public:
|
||||||
virtual ~Model() {}
|
virtual ~Model() {}
|
||||||
virtual void WriteJson(JsonWriter& Writer) const = 0;
|
virtual void WriteJson(JsonWriter& Writer) const = 0;
|
||||||
virtual bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) = 0;
|
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OPENAPI_API Request
|
class OPENAPI_API Request
|
||||||
@ -42,7 +42,7 @@ class OPENAPI_API Response
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Response() {}
|
virtual ~Response() {}
|
||||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) = 0;
|
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||||
|
|
||||||
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
||||||
bool IsSuccessful() const { return Successful; }
|
bool IsSuccessful() const { return Successful; }
|
||||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPICategory : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPICategory() {}
|
virtual ~OpenAPICategory() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int64> Id;
|
TOptional<int64> Id;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "Serialization/JsonSerializer.h"
|
#include "Serialization/JsonSerializer.h"
|
||||||
#include "Dom/JsonObject.h"
|
#include "Dom/JsonObject.h"
|
||||||
#include "Misc/Base64.h"
|
#include "Misc/Base64.h"
|
||||||
|
#include "PlatformHttp.h"
|
||||||
|
|
||||||
class IHttpRequest;
|
class IHttpRequest;
|
||||||
|
|
||||||
@ -205,10 +206,22 @@ inline FString CollectionToUrlString_multi(const TArray<T>& Collection, const TC
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& Value)
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const T& Value)
|
|
||||||
{
|
{
|
||||||
Writer->WriteValue(Value);
|
if (Value.IsValid())
|
||||||
|
{
|
||||||
|
FJsonSerializer::Serialize(Value.ToSharedRef(), Writer, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Writer->WriteObjectStart();
|
||||||
|
Writer->WriteObjectEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void WriteJsonValue(JsonWriter& Writer, const TArray<uint8>& Value)
|
||||||
|
{
|
||||||
|
Writer->WriteValue(ToString(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const FDateTime& Value)
|
inline void WriteJsonValue(JsonWriter& Writer, const FDateTime& Value)
|
||||||
@ -221,6 +234,12 @@ inline void WriteJsonValue(JsonWriter& Writer, const Model& Value)
|
|||||||
Value.WriteJson(Writer);
|
Value.WriteJson(Writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
||||||
|
inline void WriteJsonValue(JsonWriter& Writer, const T& Value)
|
||||||
|
{
|
||||||
|
Writer->WriteValue(Value);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TArray<T>& Value)
|
inline void WriteJsonValue(JsonWriter& Writer, const TArray<T>& Value)
|
||||||
{
|
{
|
||||||
@ -244,54 +263,8 @@ inline void WriteJsonValue(JsonWriter& Writer, const TMap<FString, T>& Value)
|
|||||||
Writer->WriteObjectEnd();
|
Writer->WriteObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& Value)
|
|
||||||
{
|
|
||||||
if (Value.IsValid())
|
|
||||||
{
|
|
||||||
FJsonSerializer::Serialize(Value.ToSharedRef(), Writer, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Writer->WriteObjectStart();
|
|
||||||
Writer->WriteObjectEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void WriteJsonValue(JsonWriter& Writer, const TArray<uint8>& Value)
|
|
||||||
{
|
|
||||||
Writer->WriteValue(ToString(Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, T& Value)
|
|
||||||
{
|
|
||||||
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
|
||||||
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
|
||||||
{
|
|
||||||
return TryGetJsonValue(JsonValue, Value);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, TOptional<T>& OptionalValue)
|
|
||||||
{
|
|
||||||
if(JsonObject->HasField(Key))
|
|
||||||
{
|
|
||||||
T Value;
|
|
||||||
if (TryGetJsonValue(JsonObject, Key, Value))
|
|
||||||
{
|
|
||||||
OptionalValue = Value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true; // Absence of optional value is not a parsing error
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, FString& Value)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, FString& Value)
|
||||||
{
|
{
|
||||||
FString TmpValue;
|
FString TmpValue;
|
||||||
@ -325,6 +298,34 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, bool& Value
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TSharedPtr<FJsonObject>& JsonObjectValue)
|
||||||
|
{
|
||||||
|
const TSharedPtr<FJsonObject>* Object;
|
||||||
|
if (JsonValue->TryGetObject(Object))
|
||||||
|
{
|
||||||
|
JsonObjectValue = *Object;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<uint8>& Value)
|
||||||
|
{
|
||||||
|
FString TmpValue;
|
||||||
|
if (JsonValue->TryGetString(TmpValue))
|
||||||
|
{
|
||||||
|
Base64UrlDecode(TmpValue, Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, Model& Value)
|
||||||
|
{
|
||||||
|
return Value.FromJson(JsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||||
{
|
{
|
||||||
@ -338,15 +339,6 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, Model& Value)
|
|
||||||
{
|
|
||||||
const TSharedPtr<FJsonObject>* Object;
|
|
||||||
if (JsonValue->TryGetObject(Object))
|
|
||||||
return Value.FromJson(*Object);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<T>& ArrayValue)
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<T>& ArrayValue)
|
||||||
{
|
{
|
||||||
@ -386,27 +378,32 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TMap<FStrin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TSharedPtr<FJsonObject>& JsonObjectValue)
|
template<typename T>
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, T& Value)
|
||||||
{
|
{
|
||||||
const TSharedPtr<FJsonObject>* Object;
|
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
||||||
if (JsonValue->TryGetObject(Object))
|
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
||||||
{
|
{
|
||||||
JsonObjectValue = *Object;
|
return TryGetJsonValue(JsonValue, Value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TArray<uint8>& Value)
|
template<typename T>
|
||||||
|
inline bool TryGetJsonValue(const TSharedPtr<FJsonObject>& JsonObject, const FString& Key, TOptional<T>& OptionalValue)
|
||||||
{
|
{
|
||||||
FString TmpValue;
|
if(JsonObject->HasField(Key))
|
||||||
if (JsonValue->TryGetString(TmpValue))
|
|
||||||
{
|
{
|
||||||
Base64UrlDecode(TmpValue, Value);
|
T Value;
|
||||||
return true;
|
if (TryGetJsonValue(JsonObject, Key, Value))
|
||||||
|
{
|
||||||
|
OptionalValue = Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
return true; // Absence of optional value is not a parsing error
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIOrder : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPIOrder() {}
|
virtual ~OpenAPIOrder() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int64> Id;
|
TOptional<int64> Id;
|
||||||
|
@ -28,7 +28,7 @@ class OPENAPI_API OpenAPIPet : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPIPet() {}
|
virtual ~OpenAPIPet() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int64> Id;
|
TOptional<int64> Id;
|
||||||
|
@ -41,7 +41,7 @@ class OPENAPI_API OpenAPIPetApi::AddPetResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~AddPetResponse() {}
|
virtual ~AddPetResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -66,7 +66,7 @@ class OPENAPI_API OpenAPIPetApi::DeletePetResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~DeletePetResponse() {}
|
virtual ~DeletePetResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -97,7 +97,7 @@ class OPENAPI_API OpenAPIPetApi::FindPetsByStatusResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~FindPetsByStatusResponse() {}
|
virtual ~FindPetsByStatusResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
TArray<OpenAPIPet> Content;
|
TArray<OpenAPIPet> Content;
|
||||||
};
|
};
|
||||||
@ -122,7 +122,7 @@ class OPENAPI_API OpenAPIPetApi::FindPetsByTagsResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~FindPetsByTagsResponse() {}
|
virtual ~FindPetsByTagsResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
TArray<OpenAPIPet> Content;
|
TArray<OpenAPIPet> Content;
|
||||||
};
|
};
|
||||||
@ -147,7 +147,7 @@ class OPENAPI_API OpenAPIPetApi::GetPetByIdResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~GetPetByIdResponse() {}
|
virtual ~GetPetByIdResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
OpenAPIPet Content;
|
OpenAPIPet Content;
|
||||||
};
|
};
|
||||||
@ -171,7 +171,7 @@ class OPENAPI_API OpenAPIPetApi::UpdatePetResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~UpdatePetResponse() {}
|
virtual ~UpdatePetResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -199,7 +199,7 @@ class OPENAPI_API OpenAPIPetApi::UpdatePetWithFormResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~UpdatePetWithFormResponse() {}
|
virtual ~UpdatePetWithFormResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -227,7 +227,7 @@ class OPENAPI_API OpenAPIPetApi::UploadFileResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~UploadFileResponse() {}
|
virtual ~UploadFileResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
OpenAPIApiResponse Content;
|
OpenAPIApiResponse Content;
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ class OPENAPI_API OpenAPIStoreApi::DeleteOrderResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~DeleteOrderResponse() {}
|
virtual ~DeleteOrderResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -63,7 +63,7 @@ class OPENAPI_API OpenAPIStoreApi::GetInventoryResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~GetInventoryResponse() {}
|
virtual ~GetInventoryResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
TMap<FString, int32> Content;
|
TMap<FString, int32> Content;
|
||||||
};
|
};
|
||||||
@ -88,7 +88,7 @@ class OPENAPI_API OpenAPIStoreApi::GetOrderByIdResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~GetOrderByIdResponse() {}
|
virtual ~GetOrderByIdResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
OpenAPIOrder Content;
|
OpenAPIOrder Content;
|
||||||
};
|
};
|
||||||
@ -112,7 +112,7 @@ class OPENAPI_API OpenAPIStoreApi::PlaceOrderResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~PlaceOrderResponse() {}
|
virtual ~PlaceOrderResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
OpenAPIOrder Content;
|
OpenAPIOrder Content;
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPITag : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPITag() {}
|
virtual ~OpenAPITag() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int64> Id;
|
TOptional<int64> Id;
|
||||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIUser : public Model
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~OpenAPIUser() {}
|
virtual ~OpenAPIUser() {}
|
||||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
void WriteJson(JsonWriter& Writer) const final;
|
void WriteJson(JsonWriter& Writer) const final;
|
||||||
|
|
||||||
TOptional<int64> Id;
|
TOptional<int64> Id;
|
||||||
|
@ -40,7 +40,7 @@ class OPENAPI_API OpenAPIUserApi::CreateUserResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~CreateUserResponse() {}
|
virtual ~CreateUserResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -64,7 +64,7 @@ class OPENAPI_API OpenAPIUserApi::CreateUsersWithArrayInputResponse : public Res
|
|||||||
public:
|
public:
|
||||||
virtual ~CreateUsersWithArrayInputResponse() {}
|
virtual ~CreateUsersWithArrayInputResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -88,7 +88,7 @@ class OPENAPI_API OpenAPIUserApi::CreateUsersWithListInputResponse : public Resp
|
|||||||
public:
|
public:
|
||||||
virtual ~CreateUsersWithListInputResponse() {}
|
virtual ~CreateUsersWithListInputResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -113,7 +113,7 @@ class OPENAPI_API OpenAPIUserApi::DeleteUserResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~DeleteUserResponse() {}
|
virtual ~DeleteUserResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -137,7 +137,7 @@ class OPENAPI_API OpenAPIUserApi::GetUserByNameResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~GetUserByNameResponse() {}
|
virtual ~GetUserByNameResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
OpenAPIUser Content;
|
OpenAPIUser Content;
|
||||||
};
|
};
|
||||||
@ -163,7 +163,7 @@ class OPENAPI_API OpenAPIUserApi::LoginUserResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~LoginUserResponse() {}
|
virtual ~LoginUserResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
FString Content;
|
FString Content;
|
||||||
};
|
};
|
||||||
@ -185,7 +185,7 @@ class OPENAPI_API OpenAPIUserApi::LogoutUserResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~LogoutUserResponse() {}
|
virtual ~LogoutUserResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -212,7 +212,7 @@ class OPENAPI_API OpenAPIUserApi::UpdateUserResponse : public Response
|
|||||||
public:
|
public:
|
||||||
virtual ~UpdateUserResponse() {}
|
virtual ~UpdateUserResponse() {}
|
||||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -147,3 +147,4 @@ func (v *NullableModel200Response) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@ import (
|
|||||||
// AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType
|
// AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType
|
||||||
type AdditionalPropertiesAnyType struct {
|
type AdditionalPropertiesAnyType struct {
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
|
AdditionalProperties map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type _AdditionalPropertiesAnyType AdditionalPropertiesAnyType
|
||||||
|
|
||||||
// NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object
|
// NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object
|
||||||
// This constructor will assign default values to properties that have it defined,
|
// This constructor will assign default values to properties that have it defined,
|
||||||
// and makes sure properties required by API are set, but the set of arguments
|
// and makes sure properties required by API are set, but the set of arguments
|
||||||
@ -72,9 +75,31 @@ func (o AdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) {
|
|||||||
if o.Name != nil {
|
if o.Name != nil {
|
||||||
toSerialize["name"] = o.Name
|
toSerialize["name"] = o.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key, value := range o.AdditionalProperties {
|
||||||
|
toSerialize[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
return json.Marshal(toSerialize)
|
return json.Marshal(toSerialize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *AdditionalPropertiesAnyType) UnmarshalJSON(bytes []byte) (err error) {
|
||||||
|
varAdditionalPropertiesAnyType := _AdditionalPropertiesAnyType{}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bytes, &varAdditionalPropertiesAnyType); err == nil {
|
||||||
|
*o = AdditionalPropertiesAnyType(varAdditionalPropertiesAnyType)
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalProperties := make(map[string]interface{})
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||||
|
delete(additionalProperties, "name")
|
||||||
|
o.AdditionalProperties = additionalProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
type NullableAdditionalPropertiesAnyType struct {
|
type NullableAdditionalPropertiesAnyType struct {
|
||||||
value *AdditionalPropertiesAnyType
|
value *AdditionalPropertiesAnyType
|
||||||
isSet bool
|
isSet bool
|
||||||
@ -111,3 +136,4 @@ func (v *NullableAdditionalPropertiesAnyType) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesArray) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesBoolean) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -471,3 +471,4 @@ func (v *NullableAdditionalPropertiesClass) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesInteger) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesNumber) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesObject) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesString) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,3 +144,4 @@ func (v *NullableAnimal) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,3 +183,4 @@ func (v *NullableApiResponse) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableArrayOfArrayOfNumberOnly) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableArrayOfNumberOnly) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,3 +183,4 @@ func (v *NullableArrayTest) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,3 +120,4 @@ func (v *NullableBigCat) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableBigCatAllOf) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,3 +292,4 @@ func (v *NullableCapitalization) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,3 +120,4 @@ func (v *NullableCat) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableCatAllOf) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,3 +142,4 @@ func (v *NullableCategory) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableClassModel) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableClient) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,3 +120,4 @@ func (v *NullableDog) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableDogAllOf) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,3 +147,4 @@ func (v *NullableEnumArrays) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,3 +248,4 @@ func (v *NullableEnumTest) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,3 +112,4 @@ func (v *NullableFile) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,3 +147,4 @@ func (v *NullableFileSchemaTestClass) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -553,3 +553,4 @@ func (v *NullableFormatTest) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,3 +147,4 @@ func (v *NullableHasOnlyReadOnly) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableList) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,3 +219,4 @@ func (v *NullableMapTest) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,3 +184,4 @@ func (v *NullableMixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(src
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,3 +212,4 @@ func (v *NullableName) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,3 +111,4 @@ func (v *NullableNumberOnly) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,3 +297,4 @@ func (v *NullableOrder) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,3 +183,4 @@ func (v *NullableOuterComposite) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,3 +278,4 @@ func (v *NullablePet) UnmarshalJSON(src []byte) error {
|
|||||||
return json.Unmarshal(src, &v.value)
|
return json.Unmarshal(src, &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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