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
|
||||
- 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: Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.3.1
|
||||
- ps: Install-Module Pester -Force -Scope CurrentUser
|
||||
build_script:
|
||||
- dotnet --info
|
||||
# build C# API client (netcore)
|
||||
|
@ -12,6 +12,7 @@ sidebar_label: go-experimental
|
||||
|packageVersion|Go package version.| |1.0.0|
|
||||
|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|
|
||||
|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|
|
||||
|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|
|
||||
|
@ -11,6 +11,7 @@ sidebar_label: powershell
|
||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||
|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|
|
||||
|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
|
||||
|
||||
|
@ -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:
|
||||
|
||||
```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.
|
||||
|
@ -230,7 +230,7 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
@Option(name = {"--log-to-stderr"},
|
||||
title = "Log to STDERR",
|
||||
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;
|
||||
|
||||
@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()) {
|
||||
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);
|
||||
}
|
||||
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." +
|
||||
"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.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.OnceLogger.once;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
@ -210,6 +209,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if (name.matches("^\\d.*"))
|
||||
name = "Var" + name;
|
||||
|
||||
if ("AdditionalProperties".equals(name)) {
|
||||
// AdditionalProperties is a reserved field (additionalProperties: true), use AdditionalPropertiesField instead
|
||||
return "AdditionalPropertiesField";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -404,12 +408,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
/**
|
||||
* Determines the golang instantiation type of the specified schema.
|
||||
*
|
||||
* <p>
|
||||
* This function is called when the input schema is a map, and specifically
|
||||
* when the 'additionalProperties' attribute is present in the OAS specification.
|
||||
* Codegen invokes this function to resolve the "parent" association to
|
||||
* 'additionalProperties'.
|
||||
*
|
||||
* <p>
|
||||
* 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).
|
||||
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
|
||||
@ -417,7 +421,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
* This is the specific scenario when codegen invokes this function.
|
||||
*
|
||||
* @param property the input schema
|
||||
*
|
||||
* @return the golang instantiation type of the specified property.
|
||||
*/
|
||||
@Override
|
||||
|
@ -497,13 +497,20 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
|
||||
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 _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
//Unreal variable names are CamelCase
|
||||
return camelize(name, false);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
|
||||
protected String goImportAlias = "openapiclient";
|
||||
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||
|
||||
public GoClientExperimentalCodegen() {
|
||||
super();
|
||||
@ -44,6 +45,8 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
usesOptionals = false;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -205,9 +222,12 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
||||
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;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
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 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`.
|
||||
@ -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.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(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC));
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
@ -535,6 +536,14 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
this.powershellGalleryUrl = powershellGalleryUrl;
|
||||
}
|
||||
|
||||
public void setUseOneOfDiscriminatorLookup(boolean useOneOfDiscriminatorLookup) {
|
||||
this.useOneOfDiscriminatorLookup = useOneOfDiscriminatorLookup;
|
||||
}
|
||||
|
||||
public boolean getUseOneOfDiscriminatorLookup() {
|
||||
return this.useOneOfDiscriminatorLookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
@ -550,6 +559,12 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
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)) {
|
||||
// get the last segment of the URL
|
||||
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
||||
@ -907,6 +922,31 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
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;
|
||||
|
@ -722,7 +722,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,9 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
@ -196,15 +197,15 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
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
|
||||
if (!(ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p))) {
|
||||
throw new RuntimeException("passed schema must be of type Date or DateTime");
|
||||
}
|
||||
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
|
||||
DateFormat iso8601Date = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
|
||||
DateFormat iso8601DateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT);
|
||||
TimeZone utc = TimeZone.getTimeZone("UTC");
|
||||
iso8601Date.setTimeZone(utc);
|
||||
iso8601DateTime.setTimeZone(utc);
|
||||
DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE;
|
||||
DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) {
|
||||
List<Object> currentEnum = p.getEnum();
|
||||
List<String> fixedEnum = new ArrayList<String>();
|
||||
String fixedValue = null;
|
||||
Date date = null;
|
||||
OffsetDateTime date = null;
|
||||
if (currentEnum != null && !currentEnum.isEmpty()) {
|
||||
for (Object enumItem : currentEnum) {
|
||||
date = (Date) enumItem;
|
||||
date = (OffsetDateTime) enumItem;
|
||||
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
||||
fixedEnum.add(fixedValue);
|
||||
}
|
||||
@ -251,15 +249,21 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
// convert the example if it exists
|
||||
Object currentExample = p.getExample();
|
||||
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);
|
||||
fixedEnum.add(fixedValue);
|
||||
p.setExample(fixedValue);
|
||||
LOGGER.warn(fixedValue);
|
||||
}
|
||||
|
||||
// fix defaultObject
|
||||
if (defaultObject != null) {
|
||||
date = (Date) defaultObject;
|
||||
date = (OffsetDateTime) defaultObject;
|
||||
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
|
||||
p.setDefault(fixedValue);
|
||||
defaultObject = fixedValue;
|
||||
@ -417,14 +421,12 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
// 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);
|
||||
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
|
||||
// add a single property to the model so we can have a way to access validations
|
||||
result.isAlias = true;
|
||||
@ -843,7 +845,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
postProcessModelProperty(result, prop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -922,7 +923,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
* @return a comma-separated string representation of the Python types
|
||||
*/
|
||||
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;
|
||||
if (")".equals(suffix)) {
|
||||
fullSuffix = "," + suffix;
|
||||
|
@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
{{#isOAuth}}
|
||||
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor;
|
||||
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
|
||||
import org.springframework.security.oauth2.client.OAuth2ClientContext;
|
||||
{{#isApplication}}
|
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
|
||||
{{/isApplication}}
|
||||
@ -71,8 +72,14 @@ public class ClientConfiguration {
|
||||
{{#isOAuth}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails());
|
||||
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor(OAuth2ClientContext oAuth2ClientContext) {
|
||||
return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, {{{name}}}ResourceDetails());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
public OAuth2ClientContext oAuth2ClientContext() {
|
||||
return new DefaultOAuth2ClientContext();
|
||||
}
|
||||
|
||||
{{#isCode}}
|
||||
|
@ -15,5 +15,6 @@ public class {{unrealModuleName}} : ModuleRules
|
||||
"Json",
|
||||
}
|
||||
);
|
||||
PCHUsage = PCHUsageMode.NoPCHs;
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ public:
|
||||
{{#responses.0}}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
{{/responses.0}}
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
{{#returnType}}{{{returnType}}} Content;{{/returnType}}
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Serialization/JsonSerializer.h"
|
||||
#include "Dom/JsonObject.h"
|
||||
#include "Misc/Base64.h"
|
||||
#include "PlatformHttp.h"
|
||||
|
||||
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 T& Value)
|
||||
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& 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)
|
||||
@ -212,6 +225,12 @@ inline void WriteJsonValue(JsonWriter& Writer, const Model& Value)
|
||||
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>
|
||||
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();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
FString TmpValue;
|
||||
@ -316,6 +289,34 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, bool& Value
|
||||
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>
|
||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||
{
|
||||
@ -329,15 +330,6 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||
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>
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (JsonValue->TryGetObject(Object))
|
||||
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
||||
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
||||
{
|
||||
JsonObjectValue = *Object;
|
||||
return true;
|
||||
return TryGetJsonValue(JsonValue, Value);
|
||||
}
|
||||
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 (JsonValue->TryGetString(TmpValue))
|
||||
if(JsonObject->HasField(Key))
|
||||
{
|
||||
Base64UrlDecode(TmpValue, Value);
|
||||
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
|
||||
}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "PlatformHttp.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
#include "Misc/Paths.h"
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}}
|
||||
|
@ -18,7 +18,7 @@ class {{dllapi}} Model
|
||||
public:
|
||||
virtual ~Model() {}
|
||||
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
|
||||
@ -33,7 +33,7 @@ class {{dllapi}} Response
|
||||
{
|
||||
public:
|
||||
virtual ~Response() {}
|
||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) = 0;
|
||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||
|
||||
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
||||
bool IsSuccessful() const { return Successful; }
|
||||
|
@ -21,9 +21,26 @@ class {{dllapi}} {{classname}} : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~{{classname}}() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) 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}}
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
|
@ -11,6 +11,54 @@ namespace {{this}}
|
||||
{
|
||||
{{/cppNamespaceDeclarations}}
|
||||
{{#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}}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
@ -65,9 +113,10 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, {{classname
|
||||
{{/hasEnums}}
|
||||
void {{classname}}::WriteJson(JsonWriter& Writer) const
|
||||
{
|
||||
{{#parent}}
|
||||
#error inheritance not handled right now
|
||||
{{/parent}}
|
||||
{{#isString}}
|
||||
WriteJsonValue(Writer, Value);
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
Writer->WriteObjectStart();
|
||||
{{#vars}}
|
||||
{{#required}}
|
||||
@ -81,18 +130,29 @@ void {{classname}}::WriteJson(JsonWriter& Writer) const
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
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;
|
||||
|
||||
{{#vars}}
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("{{baseName}}"), {{name}});
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("{{baseName}}"), {{name}});
|
||||
{{/vars}}
|
||||
|
||||
return ParseSuccess;
|
||||
{{/isString}}
|
||||
}
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
{{#cppNamespaceDeclarations}}
|
||||
|
@ -15,6 +15,35 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
{{/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}}
|
||||
// try to unmarshal JSON data into {{{.}}}
|
||||
err = json.Unmarshal(data, &dst.{{{.}}});
|
||||
|
@ -24,9 +24,40 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
{{/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}}
|
||||
// try to unmarshal data into {{{.}}}
|
||||
err = json.Unmarshal(data, &dst.{{{.}}});
|
||||
err = json.Unmarshal(data, &dst.{{{.}}})
|
||||
if err == nil {
|
||||
json{{{.}}}, _ := json.Marshal(dst.{{{.}}})
|
||||
if string(json{{{.}}}) == "{}" { // empty struct
|
||||
|
@ -13,8 +13,15 @@ type {{classname}} struct {
|
||||
{{/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}}`
|
||||
{{/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
|
||||
// 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
|
||||
@ -246,7 +253,35 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
{{#vendorExtensions.x-additional-properties}}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
{{/vendorExtensions.x-additional-properties}}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
{{#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}}
|
@ -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}}}' {
|
||||
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
|
||||
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
||||
#$TestResult | Should BeOfType TODO
|
||||
#$TestResult.property | Should Be 0
|
||||
#$TestResult | Should -BeOfType TODO
|
||||
#$TestResult.property | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,35 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
}
|
||||
|
||||
{{/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}}
|
||||
if ($match -ne 0) { # no match yet
|
||||
# try to match {{{.}}} defined in the anyOf schemas
|
||||
|
@ -38,6 +38,37 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
}
|
||||
|
||||
{{/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}}
|
||||
# try to match {{{.}}} defined in the oneOf schemas
|
||||
try {
|
||||
|
@ -129,13 +129,24 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$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}}}
|
||||
$AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}})
|
||||
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
|
||||
{{^vendorExtensions.x-additional-properties}}
|
||||
if (!($AllProperties.Contains($name))) {
|
||||
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}}
|
||||
@ -166,6 +177,9 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
"<<baseName>>" = ${<<name>>}
|
||||
<</allVars>>
|
||||
<<={{ }}=>>
|
||||
{{#vendorExtensions.x-additional-properties}}
|
||||
"AdditionalProperties" = ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties
|
||||
{{/vendorExtensions.x-additional-properties}}
|
||||
}
|
||||
|
||||
return $PSO
|
||||
|
@ -6,8 +6,8 @@ Describe -tag '{{{packageName}}}' -name '{{{apiNamePrefix}}}{{{classname}}}' {
|
||||
It 'Initialize-{{{apiNamePrefix}}}{{{classname}}}' {
|
||||
# a simple test to create an object
|
||||
#$NewObject = Initialize-{{{apiNamePrefix}}}{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
|
||||
#$NewObject | Should BeOfType {{classname}}
|
||||
#$NewObject.property | Should Be 0
|
||||
#$NewObject | Should -BeOfType {{classname}}
|
||||
#$NewObject.property | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ class {{classname}}(object):
|
||||
{{/notes}}
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
{{#sortParamsByRequiredFlag}}
|
||||
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
||||
{{/sortParamsByRequiredFlag}}
|
||||
@ -46,20 +47,24 @@ class {{classname}}(object):
|
||||
{{/sortParamsByRequiredFlag}}
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
{{#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}}
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
:type async_req: bool, optional
|
||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is True.
|
||||
:type _preload_content: bool, optional
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
:return: Returns the result object.
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
:rtype: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
"""
|
||||
kwargs['_return_http_data_only'] = True
|
||||
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
|
||||
@ -72,6 +77,7 @@ class {{classname}}(object):
|
||||
{{/notes}}
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
{{#sortParamsByRequiredFlag}}
|
||||
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
|
||||
{{/sortParamsByRequiredFlag}}
|
||||
@ -80,22 +86,27 @@ class {{classname}}(object):
|
||||
{{/sortParamsByRequiredFlag}}
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
{{#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}}
|
||||
: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
|
||||
and headers
|
||||
:type _return_http_data_only: bool, optional
|
||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is True.
|
||||
:type _preload_content: bool, optional
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(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,
|
||||
returns the request thread.
|
||||
:rtype: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
"""
|
||||
|
||||
{{#servers.0}}
|
||||
|
@ -107,7 +107,7 @@ class {{classname}}(object):
|
||||
{{/description}}
|
||||
|
||||
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
||||
:type: {{dataType}}
|
||||
:type {{name}}: {{dataType}}
|
||||
"""
|
||||
{{^isNullable}}
|
||||
{{#required}}
|
||||
|
@ -66,6 +66,7 @@ class {{classname}}(object):
|
||||
{{/notes}}
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
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)
|
||||
>>> result = thread.get()
|
||||
|
||||
|
@ -291,6 +291,7 @@ class ApiClient(object):
|
||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||
:param _check_type: boolean, whether to check the types of the data
|
||||
received from the server
|
||||
:type _check_type: bool
|
||||
|
||||
:return: deserialized object.
|
||||
"""
|
||||
@ -350,22 +351,28 @@ class ApiClient(object):
|
||||
(float, none_type)
|
||||
([int, 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`.
|
||||
:type files: dict
|
||||
:param async_req bool: execute request asynchronously
|
||||
:type async_req: bool, optional
|
||||
:param _return_http_data_only: response data without head status code
|
||||
and headers
|
||||
:type _return_http_data_only: bool, optional
|
||||
:param collection_formats: dict of collection formats for path, query,
|
||||
header, and post parameters.
|
||||
:type collection_formats: dict, optional
|
||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is True.
|
||||
:type _preload_content: bool, optional
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:param _check_type: boolean describing if the data back from the server
|
||||
should have its type checked.
|
||||
:type _check_type: bool, optional
|
||||
:return:
|
||||
If async_req parameter is True,
|
||||
the request will be called asynchronously.
|
||||
@ -559,9 +566,9 @@ class ApiClient(object):
|
||||
:param headers: Header parameters dict to be updated.
|
||||
:param querys: Query parameters tuple list to be updated.
|
||||
:param auth_settings: Authentication setting identifiers list.
|
||||
:resource_path: A string representation of the HTTP request resource path.
|
||||
:method: A string representation of the HTTP request method.
|
||||
:body: A object representing the body of the HTTP request.
|
||||
:param resource_path: A string representation of the HTTP request resource path.
|
||||
:param method: A string representation of the HTTP request method.
|
||||
:param body: A object representing the body of the HTTP request.
|
||||
The object type is the return value of sanitize_for_serialization().
|
||||
"""
|
||||
if not auth_settings:
|
||||
|
@ -37,7 +37,12 @@ from {{packageName}}.model_utils import ( # noqa: F401
|
||||
{{> python-experimental/model_templates/model_simple }}
|
||||
{{/isAlias}}
|
||||
{{^isAlias}}
|
||||
{{#isArrayModel}}
|
||||
{{> python-experimental/model_templates/model_simple }}
|
||||
{{/isArrayModel}}
|
||||
{{^isArrayModel}}
|
||||
{{> python-experimental/model_templates/model_normal }}
|
||||
{{/isArrayModel}}
|
||||
{{/isAlias}}
|
||||
{{/interfaces}}
|
||||
{{#interfaces}}
|
||||
|
@ -41,7 +41,7 @@ export class {{classname}} extends BaseAPI {
|
||||
{{#hasParams}}
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
throwIfNullOrUndefined({{> paramNamePartial}}, '{{nickname}}');
|
||||
throwIfNullOrUndefined({{> paramNamePartial}}, '{{> paramNamePartial}}', '{{nickname}}');
|
||||
{{/required}}
|
||||
{{/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) {
|
||||
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.media.*;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -268,7 +270,7 @@ public class PythonClientExperimentalTest {
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.classVarName, "sample");
|
||||
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.imports.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);
|
||||
}
|
||||
|
||||
@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
|
||||
banana:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
properties:
|
||||
lengthCm:
|
||||
type: number
|
||||
|
@ -699,6 +699,7 @@ components:
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
additionalProperties: true
|
||||
title: Pet Tag
|
||||
description: A tag for a pet
|
||||
type: object
|
||||
|
@ -758,6 +758,8 @@ paths:
|
||||
description: None
|
||||
type: string
|
||||
format: date-time
|
||||
default: '2010-02-01T10:20:10.11111+01:00'
|
||||
example: '2020-02-02T20:20:20.22222Z'
|
||||
password:
|
||||
description: None
|
||||
type: string
|
||||
@ -1097,6 +1099,19 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$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:
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
description: petstore server
|
||||
@ -1202,6 +1217,7 @@ components:
|
||||
shipDate:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2020-02-02T20:20:20.000222Z'
|
||||
status:
|
||||
type: string
|
||||
description: Order Status
|
||||
@ -1466,9 +1482,11 @@ components:
|
||||
date:
|
||||
type: string
|
||||
format: date
|
||||
example: '2020-02-02'
|
||||
dateTime:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2007-12-03T10:15:30+01:00'
|
||||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
@ -2069,3 +2087,12 @@ components:
|
||||
properties:
|
||||
name:
|
||||
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/jersey1</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/retrofit2</module>
|
||||
<module>samples/client/petstore/java/retrofit2rx</module>
|
||||
|
@ -26,5 +26,6 @@ public class OpenAPI : ModuleRules
|
||||
"Json",
|
||||
}
|
||||
);
|
||||
PCHUsage = PCHUsageMode.NoPCHs;
|
||||
}
|
||||
}
|
@ -38,14 +38,19 @@ void OpenAPIApiResponse::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("code"), Code);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("type"), Type);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("message"), Message);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("code"), Code);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("type"), Type);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("message"), Message);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,13 +34,18 @@ void OpenAPICategory::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "PlatformHttp.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
#include "Misc/Paths.h"
|
||||
|
||||
namespace OpenAPI
|
||||
{
|
||||
|
@ -96,17 +96,22 @@ void OpenAPIOrder::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("petId"), PetId);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("quantity"), Quantity);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("shipDate"), ShipDate);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("status"), Status);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("complete"), Complete);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("petId"), PetId);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("quantity"), Quantity);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("shipDate"), ShipDate);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("status"), Status);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("complete"), Complete);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,17 +90,22 @@ void OpenAPIPet::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("category"), Category);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("photoUrls"), PhotoUrls);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("tags"), Tags);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("status"), Status);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("category"), Category);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("photoUrls"), PhotoUrls);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("tags"), Tags);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("status"), Status);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,13 +34,18 @@ void OpenAPITag::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("name"), Name);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("name"), Name);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,19 +58,24 @@ void OpenAPIUser::WriteJson(JsonWriter& Writer) const
|
||||
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;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("username"), Username);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("firstName"), FirstName);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("lastName"), LastName);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("email"), Email);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("password"), Password);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("phone"), Phone);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("userStatus"), UserStatus);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("username"), Username);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("firstName"), FirstName);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("lastName"), LastName);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("email"), Email);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("password"), Password);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("phone"), Phone);
|
||||
ParseSuccess &= TryGetJsonValue(*Object, TEXT("userStatus"), UserStatus);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIApiResponse : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPIApiResponse() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int32> Code;
|
||||
|
@ -27,7 +27,7 @@ class OPENAPI_API Model
|
||||
public:
|
||||
virtual ~Model() {}
|
||||
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
|
||||
@ -42,7 +42,7 @@ class OPENAPI_API Response
|
||||
{
|
||||
public:
|
||||
virtual ~Response() {}
|
||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) = 0;
|
||||
virtual bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) = 0;
|
||||
|
||||
void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; }
|
||||
bool IsSuccessful() const { return Successful; }
|
||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPICategory : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPICategory() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int64> Id;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Serialization/JsonSerializer.h"
|
||||
#include "Dom/JsonObject.h"
|
||||
#include "Misc/Base64.h"
|
||||
#include "PlatformHttp.h"
|
||||
|
||||
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 T& Value)
|
||||
inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonObject>& 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)
|
||||
@ -221,6 +234,12 @@ inline void WriteJsonValue(JsonWriter& Writer, const Model& Value)
|
||||
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>
|
||||
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();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
FString TmpValue;
|
||||
@ -325,6 +298,34 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, bool& Value
|
||||
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>
|
||||
inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||
{
|
||||
@ -338,15 +339,6 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, T& Value)
|
||||
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>
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (JsonValue->TryGetObject(Object))
|
||||
const TSharedPtr<FJsonValue> JsonValue = JsonObject->TryGetField(Key);
|
||||
if (JsonValue.IsValid() && !JsonValue->IsNull())
|
||||
{
|
||||
JsonObjectValue = *Object;
|
||||
return true;
|
||||
return TryGetJsonValue(JsonValue, Value);
|
||||
}
|
||||
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 (JsonValue->TryGetString(TmpValue))
|
||||
if(JsonObject->HasField(Key))
|
||||
{
|
||||
Base64UrlDecode(TmpValue, Value);
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIOrder : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPIOrder() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int64> Id;
|
||||
|
@ -28,7 +28,7 @@ class OPENAPI_API OpenAPIPet : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPIPet() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int64> Id;
|
||||
|
@ -41,7 +41,7 @@ class OPENAPI_API OpenAPIPetApi::AddPetResponse : public Response
|
||||
public:
|
||||
virtual ~AddPetResponse() {}
|
||||
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:
|
||||
virtual ~DeletePetResponse() {}
|
||||
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:
|
||||
virtual ~FindPetsByStatusResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
TArray<OpenAPIPet> Content;
|
||||
};
|
||||
@ -122,7 +122,7 @@ class OPENAPI_API OpenAPIPetApi::FindPetsByTagsResponse : public Response
|
||||
public:
|
||||
virtual ~FindPetsByTagsResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
TArray<OpenAPIPet> Content;
|
||||
};
|
||||
@ -147,7 +147,7 @@ class OPENAPI_API OpenAPIPetApi::GetPetByIdResponse : public Response
|
||||
public:
|
||||
virtual ~GetPetByIdResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
OpenAPIPet Content;
|
||||
};
|
||||
@ -171,7 +171,7 @@ class OPENAPI_API OpenAPIPetApi::UpdatePetResponse : public Response
|
||||
public:
|
||||
virtual ~UpdatePetResponse() {}
|
||||
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:
|
||||
virtual ~UpdatePetWithFormResponse() {}
|
||||
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:
|
||||
virtual ~UploadFileResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
OpenAPIApiResponse Content;
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ class OPENAPI_API OpenAPIStoreApi::DeleteOrderResponse : public Response
|
||||
public:
|
||||
virtual ~DeleteOrderResponse() {}
|
||||
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:
|
||||
virtual ~GetInventoryResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
TMap<FString, int32> Content;
|
||||
};
|
||||
@ -88,7 +88,7 @@ class OPENAPI_API OpenAPIStoreApi::GetOrderByIdResponse : public Response
|
||||
public:
|
||||
virtual ~GetOrderByIdResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
OpenAPIOrder Content;
|
||||
};
|
||||
@ -112,7 +112,7 @@ class OPENAPI_API OpenAPIStoreApi::PlaceOrderResponse : public Response
|
||||
public:
|
||||
virtual ~PlaceOrderResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
OpenAPIOrder Content;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPITag : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPITag() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int64> Id;
|
||||
|
@ -26,7 +26,7 @@ class OPENAPI_API OpenAPIUser : public Model
|
||||
{
|
||||
public:
|
||||
virtual ~OpenAPIUser() {}
|
||||
bool FromJson(const TSharedPtr<FJsonObject>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
void WriteJson(JsonWriter& Writer) const final;
|
||||
|
||||
TOptional<int64> Id;
|
||||
|
@ -40,7 +40,7 @@ class OPENAPI_API OpenAPIUserApi::CreateUserResponse : public Response
|
||||
public:
|
||||
virtual ~CreateUserResponse() {}
|
||||
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:
|
||||
virtual ~CreateUsersWithArrayInputResponse() {}
|
||||
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:
|
||||
virtual ~CreateUsersWithListInputResponse() {}
|
||||
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:
|
||||
virtual ~DeleteUserResponse() {}
|
||||
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:
|
||||
virtual ~GetUserByNameResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
OpenAPIUser Content;
|
||||
};
|
||||
@ -163,7 +163,7 @@ class OPENAPI_API OpenAPIUserApi::LoginUserResponse : public Response
|
||||
public:
|
||||
virtual ~LoginUserResponse() {}
|
||||
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
|
||||
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
|
||||
|
||||
FString Content;
|
||||
};
|
||||
@ -185,7 +185,7 @@ class OPENAPI_API OpenAPIUserApi::LogoutUserResponse : public Response
|
||||
public:
|
||||
virtual ~LogoutUserResponse() {}
|
||||
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:
|
||||
virtual ~UpdateUserResponse() {}
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,8 +16,11 @@ import (
|
||||
// AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType
|
||||
type AdditionalPropertiesAnyType struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _AdditionalPropertiesAnyType AdditionalPropertiesAnyType
|
||||
|
||||
// NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object
|
||||
// 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
|
||||
@ -72,9 +75,31 @@ func (o AdditionalPropertiesAnyType) MarshalJSON() ([]byte, error) {
|
||||
if o.Name != nil {
|
||||
toSerialize["name"] = o.Name
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
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 {
|
||||
value *AdditionalPropertiesAnyType
|
||||
isSet bool
|
||||
@ -111,3 +136,4 @@ func (v *NullableAdditionalPropertiesAnyType) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesArray) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesBoolean) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -471,3 +471,4 @@ func (v *NullableAdditionalPropertiesClass) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesInteger) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesNumber) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesObject) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableAdditionalPropertiesString) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,3 +144,4 @@ func (v *NullableAnimal) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,3 +183,4 @@ func (v *NullableApiResponse) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableArrayOfArrayOfNumberOnly) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableArrayOfNumberOnly) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,3 +183,4 @@ func (v *NullableArrayTest) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,3 +120,4 @@ func (v *NullableBigCat) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableBigCatAllOf) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,3 +292,4 @@ func (v *NullableCapitalization) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,3 +120,4 @@ func (v *NullableCat) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableCatAllOf) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,3 +142,4 @@ func (v *NullableCategory) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableClassModel) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableClient) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,3 +120,4 @@ func (v *NullableDog) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableDogAllOf) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,3 +147,4 @@ func (v *NullableEnumArrays) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -248,3 +248,4 @@ func (v *NullableEnumTest) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,3 +112,4 @@ func (v *NullableFile) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,3 +147,4 @@ func (v *NullableFileSchemaTestClass) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -553,3 +553,4 @@ func (v *NullableFormatTest) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,3 +147,4 @@ func (v *NullableHasOnlyReadOnly) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableList) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,3 +219,4 @@ func (v *NullableMapTest) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,3 +184,4 @@ func (v *NullableMixedPropertiesAndAdditionalPropertiesClass) UnmarshalJSON(src
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,3 +212,4 @@ func (v *NullableName) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableNumberOnly) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,3 +297,4 @@ func (v *NullableOrder) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,3 +183,4 @@ func (v *NullableOuterComposite) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,3 +278,4 @@ func (v *NullablePet) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,3 +147,4 @@ func (v *NullableReadOnlyFirst) UnmarshalJSON(src []byte) error {
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,3 +111,4 @@ func (v *NullableReturn) UnmarshalJSON(src []byte) error {
|
||||
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