From ae099330b9c0478d31318a77bc6d3d9690243ed2 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 29 Mar 2021 23:42:14 -0700 Subject: [PATCH 01/99] Feature fixed, samples regenerated (#9131) --- .../languages/PythonClientCodegen.java | 76 +++++++++++++------ .../languages/PythonLegacyClientCodegen.java | 2 +- .../codegen/python/PythonClientTest.java | 2 +- ...ue_8052_recursive_model_expected_value.txt | 5 +- .../client/petstore/python/docs/FakeApi.md | 4 +- .../client/petstore/python/docs/FakeApi.md | 4 +- 6 files changed, 60 insertions(+), 33 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index b38d2448d87..3b0b5deeb81 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -36,6 +36,8 @@ import org.openapitools.codegen.meta.Stability; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.github.curiousoddman.rgxgen.RgxGen; +import com.github.curiousoddman.rgxgen.config.RgxGenOption; +import com.github.curiousoddman.rgxgen.config.RgxGenProperties; import java.time.OffsetDateTime; import java.time.ZoneOffset; @@ -894,6 +896,13 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { return "\"" + in + "\""; } + @Override + public String toExampleValue(Schema schema) { + Object objExample = getObjectExample(schema); + String modelName = getModelName(schema); + return toExampleValueRecursive(modelName, schema, objExample, 1, "", 0, Sets.newHashSet()); + } + public String toExampleValue(Schema schema, Object objExample) { String modelName = getModelName(schema); return toExampleValueRecursive(modelName, schema, objExample, 1, "", 0, Sets.newHashSet()); @@ -974,7 +983,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { // checks if the current schema has already been passed in. If so, breaks the current recursive pass if (seenSchemas.contains(schema)) { if (modelName != null) { - return fullPrefix + modelName + closeChars; + return fullPrefix + closeChars; } else { // this is a recursive schema // need to add a reasonable example to avoid @@ -1050,18 +1059,39 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { return fullPrefix + example + closeChars; } else if (StringUtils.isNotBlank(schema.getPattern())) { String pattern = schema.getPattern(); - RgxGen rgxGen = new RgxGen(pattern); + /* + RxGen does not support our ECMA dialect https://github.com/curious-odd-man/RgxGen/issues/56 + So strip off the leading / and trailing / and turn on ignore case if we have it + */ + Pattern valueExtractor = Pattern.compile("^/?(.+?)/?(.?)$"); + Matcher m = valueExtractor.matcher(pattern); + RgxGen rgxGen = null; + if (m.find()) { + int groupCount = m.groupCount(); + if (groupCount == 1) { + // only pattern found + String isolatedPattern = m.group(1); + rgxGen = new RgxGen(isolatedPattern); + } else if (groupCount == 2) { + // patterns and flag found + String isolatedPattern = m.group(1); + String flags = m.group(2); + if (flags.contains("i")) { + rgxGen = new RgxGen(isolatedPattern); + RgxGenProperties properties = new RgxGenProperties(); + RgxGenOption.CASE_INSENSITIVE.setInProperties(properties, true); + rgxGen.setProperties(properties); + } else { + rgxGen = new RgxGen(isolatedPattern); + } + } + } else { + rgxGen = new RgxGen(pattern); + } + // this seed makes it so if we have [a-z] we pick a Random random = new Random(18); - String sample = rgxGen.generate(random); - // omit leading / and trailing /, omit trailing /i - Pattern valueExtractor = Pattern.compile("^/?(.+?)/?.?$"); - Matcher m = valueExtractor.matcher(sample); - if (m.find()) { - example = m.group(m.groupCount()); - } else { - example = ""; - } + example = rgxGen.generate(random); } else if (schema.getMinLength() != null) { example = ""; int len = schema.getMinLength().intValue(); @@ -1099,8 +1129,9 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { // If the example is already a list, return it directly instead of wrongly wrap it in another list return fullPrefix + objExample.toString() + closeChars; } - seenSchemas.add(schema); - example = fullPrefix + "[" + "\n" + toExampleValueRecursive(itemModelName, itemSchema, objExample, indentationLevel + 1, "", exampleLine + 1, seenSchemas) + ",\n" + closingIndentation + "]" + closeChars; + Set newSeenSchemas = new HashSet<>(seenSchemas); + newSeenSchemas.add(schema); + example = fullPrefix + "[" + "\n" + toExampleValueRecursive(itemModelName, itemSchema, objExample, indentationLevel + 1, "", exampleLine + 1, newSeenSchemas) + ",\n" + closingIndentation + "]" + closeChars; return example; } else if (ModelUtils.isMapSchema(schema)) { if (modelName == null) { @@ -1122,8 +1153,9 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { addPropPrefix = ensureQuotes(key) + ": "; } String addPropsModelName = getModelName(addPropsSchema); - seenSchemas.add(schema); - example = fullPrefix + "\n" + toExampleValueRecursive(addPropsModelName, addPropsSchema, addPropsExample, indentationLevel + 1, addPropPrefix, exampleLine + 1, seenSchemas) + ",\n" + closingIndentation + closeChars; + Set newSeenSchemas = new HashSet<>(seenSchemas); + newSeenSchemas.add(schema); + example = fullPrefix + "\n" + toExampleValueRecursive(addPropsModelName, addPropsSchema, addPropsExample, indentationLevel + 1, addPropPrefix, exampleLine + 1, newSeenSchemas) + ",\n" + closingIndentation + closeChars; } else { example = fullPrefix + closeChars; } @@ -1146,11 +1178,9 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { return fullPrefix + closeChars; } } - // Adds schema to seenSchemas before running example model function. romoves schema after running - // the function. It also doesnt keep track of any schemas within the ObjectModel. - seenSchemas.add(schema); - String exampleForObjectModel = exampleForObjectModel(schema, fullPrefix, closeChars, null, indentationLevel, exampleLine, closingIndentation, seenSchemas); - seenSchemas.remove(schema); + Set newSeenSchemas = new HashSet<>(seenSchemas); + newSeenSchemas.add(schema); + String exampleForObjectModel = exampleForObjectModel(schema, fullPrefix, closeChars, null, indentationLevel, exampleLine, closingIndentation, newSeenSchemas); return exampleForObjectModel; } else if (ModelUtils.isComposedSchema(schema)) { // TODO add examples for composed schema models without discriminators @@ -1167,9 +1197,9 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { cp.setExample(discPropNameValue); // Adds schema to seenSchemas before running example model function. romoves schema after running // the function. It also doesnt keep track of any schemas within the ObjectModel. - seenSchemas.add(modelSchema); - String exampleForObjectModel = exampleForObjectModel(modelSchema, fullPrefix, closeChars, cp, indentationLevel, exampleLine, closingIndentation, seenSchemas); - seenSchemas.remove(modelSchema); + Set newSeenSchemas = new HashSet<>(seenSchemas); + newSeenSchemas.add(schema); + String exampleForObjectModel = exampleForObjectModel(modelSchema, fullPrefix, closeChars, cp, indentationLevel, exampleLine, closingIndentation, newSeenSchemas); return exampleForObjectModel; } else { return fullPrefix + closeChars; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java index 7d5cc631a8b..8a213a37757 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java @@ -17,6 +17,7 @@ package org.openapitools.codegen.languages; +import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.meta.features.*; @@ -430,5 +431,4 @@ public class PythonLegacyClientCodegen extends AbstractPythonCodegen implements public String generatePackageName(String packageName) { return underscore(packageName.replaceAll("[^\\w]+", "")); } - } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientTest.java index 4face161d7e..842d6a2851a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientTest.java @@ -460,7 +460,7 @@ public class PythonClientTest { expectedValue = expectedValue.replaceAll("\\r\\n", "\n"); - Assert.assertEquals(expectedValue.trim(), exampleValue.trim()); + Assert.assertEquals(exampleValue.trim(), expectedValue.trim()); } diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_8052_recursive_model_expected_value.txt b/modules/openapi-generator/src/test/resources/3_0/issue_8052_recursive_model_expected_value.txt index 98ef62651fb..aad2924c9db 100644 --- a/modules/openapi-generator/src/test/resources/3_0/issue_8052_recursive_model_expected_value.txt +++ b/modules/openapi-generator/src/test/resources/3_0/issue_8052_recursive_model_expected_value.txt @@ -1,9 +1,6 @@ GeoJsonGeometry( type="GeometryCollection", geometries=[ - GeoJsonGeometry( - type="GeometryCollection", - geometries=[], - ), + GeoJsonGeometry(), ], ) \ No newline at end of file diff --git a/samples/client/petstore/python/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index a107342b75c..bfd6467215b 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -842,13 +842,13 @@ with petstore_api.ApiClient(configuration) as api_client: api_instance = fake_api.FakeApi(api_client) number = 32.1 # float | None double = 67.8 # float | None - pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + pattern_without_delimiter = "Aj" # str | None byte = 'YQ==' # str | None integer = 10 # int | None (optional) int32 = 20 # int | None (optional) int64 = 1 # int | None (optional) float = 3.14 # float | None (optional) - string = "a" # str | None (optional) + string = "A" # str | None (optional) binary = open('/path/to/file', 'rb') # file_type | None (optional) date = dateutil_parser('1970-01-01').date() # date | None (optional) date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional) diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md index ea6886d682b..3bb042e8845 100644 --- a/samples/openapi3/client/petstore/python/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md @@ -1146,13 +1146,13 @@ with petstore_api.ApiClient(configuration) as api_client: api_instance = fake_api.FakeApi(api_client) number = 32.1 # float | None double = 67.8 # float | None - pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + pattern_without_delimiter = "Aj" # str | None byte = 'YQ==' # str | None integer = 10 # int | None (optional) int32 = 20 # int | None (optional) int64 = 1 # int | None (optional) float = 3.14 # float | None (optional) - string = "a" # str | None (optional) + string = "A" # str | None (optional) binary = open('/path/to/file', 'rb') # file_type | None (optional) date = dateutil_parser('1970-01-01').date() # date | None (optional) date_time = dateutil_parser('2020-02-02T20:20:20.22222Z') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') From e1ef00903e91dd46029dbea26fa6b2818d5276b5 Mon Sep 17 00:00:00 2001 From: Luca Mazzanti Date: Tue, 30 Mar 2021 12:10:08 +0200 Subject: [PATCH 02/99] [csharp][netcore-httpclient] Reuse HttpClient, Allow use of external HttpClient. Patch to previous PR. (#9109) * [csharp][netcore-httpclient] Reuse HttpClient, Allow use of external HttpClient. * Updated samples * Removed local variables no more useful * Added InvalidOperationException when used a configuration not supported for the constructor * Updated samples --- .../resources/csharp-netcore/README.mustache | 21 ++- .../libraries/httpclient/ApiClient.mustache | 167 +++++++++++------- .../libraries/httpclient/api.mustache | 162 +++++++++++++++-- .../OpenAPIClient-httpclient/README.md | 18 +- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Api/FakeApi.cs | 154 ++++++++++++++-- .../Api/FakeClassnameTags123Api.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Api/PetApi.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Api/UserApi.cs | 154 ++++++++++++++-- .../src/Org.OpenAPITools/Client/ApiClient.cs | 167 +++++++++++------- .../OpenAPIClient-net47/README.md | 3 +- .../OpenAPIClient-net5.0/README.md | 3 +- .../csharp-netcore/OpenAPIClient/README.md | 3 +- .../OpenAPIClientCore/README.md | 3 +- 16 files changed, 1342 insertions(+), 283 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache index e9e3655c5c2..c5f3c0eadfa 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache @@ -55,7 +55,8 @@ Install-Package CompareNETObjects ``` {{#useRestSharp}} -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742). +NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406). {{/useRestSharp}} @@ -102,7 +103,10 @@ c.Proxy = webProxy; ``` {{#useHttpClient}} -To use your own HttpClient instances just pass them to the ApiClass constructor. +### Connections +Each ApiClass (properly the ApiClient inside it) will create an istance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method. + +To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHander (see [here](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net) for details). To use your own HttpClient instance just pass it to the ApiClass constructor. ```csharp HttpClientHandler yourHandler = new HttpClientHandler(); @@ -110,17 +114,20 @@ HttpClient yourHttpClient = new HttpClient(yourHandler); var api = new YourApiClass(yourHttpClient, yourHandler); ``` -If you want to use an HttpClient and don't have access to the handler, for example in a DI context in aspnetcore when -using IHttpClientFactory. You need to disable the features that require handler access: +If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory. ```csharp HttpClient yourHttpClient = new HttpClient(); -var api = new YourApiClass(yourHttpClient, null, true); +var api = new YourApiClass(yourHttpClient); ``` +You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available. -The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. -You need to either manually handle those in your setup of the HttpClient or they won't be available. +Here an example of DI setup in a sample web project: +```csharp +services.AddHttpClient(httpClient => + new PetApi(httpClient)); +``` {{/useHttpClient}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache index 23ba41d1a0f..bdc24c21a17 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache @@ -161,16 +161,16 @@ namespace {{packageName}}.Client /// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios), /// encapsulating general REST accessor use cases. /// + /// + /// The Dispose method will manage the HttpClient lifecycle when not passed by constructor. + /// {{>visibility}} partial class ApiClient : IDisposable, ISynchronousClient{{#supportsAsync}}, IAsynchronousClient{{/supportsAsync}} { private readonly String _baseUrl; - private readonly HttpClientHandler _httpClientHandler; - private readonly bool _disposeHandler; - private readonly HttpClient _httpClient; - private readonly bool _disposeClient; - - private readonly bool _disableHandlerFeatures; + private readonly HttpClientHandler _httpClientHandler; + private readonly HttpClient _httpClient; + private readonly bool _disposeClient; /// /// Specifies the settings on a object. @@ -192,37 +192,88 @@ namespace {{packageName}}.Client /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler - public ApiClient(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : - this({{packageName}}.Client.GlobalConfiguration.Instance.BasePath, client, handler, disableHandlerFeatures) - { + public ApiClient() : + this({{packageName}}.Client.GlobalConfiguration.Instance.BasePath) + { } - + /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// /// The target service's base path in URL format. - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public ApiClient(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) - { - if (string.IsNullOrEmpty(basePath)) - throw new ArgumentException("basePath cannot be empty"); + public ApiClient(String basePath) + { + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - _baseUrl = basePath; - if((client != null && handler == null) && !disableHandlerFeatures) { - throw new ArgumentException("If providing HttpClient, you also need to provide its handler or disable features requiring the handler, see README.md"); - } - - _disableHandlerFeatures = disableHandlerFeatures; - _httpClientHandler = handler ?? new HttpClientHandler(); - _disposeHandler = handler == null; - _httpClient = client ?? new HttpClient(_httpClientHandler, false); - _disposeClient = client == null; + _httpClientHandler = new HttpClientHandler(); + _httpClient = new HttpClient(_httpClientHandler, true); + _disposeClient = true; + _baseUrl = basePath; + } + + /// + /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// + /// An instance of HttpClient. + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client) : + this(client, {{packageName}}.Client.GlobalConfiguration.Instance.BasePath) + { + } + + /// + /// Initializes a new instance of the + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClient = client; + _baseUrl = basePath; + } + + /// + /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + public ApiClient(HttpClient client, HttpClientHandler handler) : + this(client, handler, {{packageName}}.Client.GlobalConfiguration.Instance.BasePath) + { + } + + /// + /// Initializes a new instance of the . + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + public ApiClient(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (handler == null) throw new ArgumentNullException("handler cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClientHandler = handler; + _httpClient = client; + _baseUrl = basePath; } /// @@ -233,9 +284,6 @@ namespace {{packageName}}.Client if(_disposeClient) { _httpClient.Dispose(); } - if(_disposeHandler) { - _httpClientHandler.Dispose(); - } } /// Prepares multipart/form-data content @@ -373,10 +421,10 @@ namespace {{packageName}}.Client return request; } - partial void InterceptRequest(HttpRequestMessage req, HttpClientHandler handler); + partial void InterceptRequest(HttpRequestMessage req); partial void InterceptResponse(HttpRequestMessage req, HttpResponseMessage response); - private ApiResponse ToApiResponse(HttpResponseMessage response, object responseData, HttpClientHandler handler, Uri uri) + private ApiResponse ToApiResponse(HttpResponseMessage response, object responseData, Uri uri) { T result = (T) responseData; string rawContent = response.Content.ToString(); @@ -405,18 +453,15 @@ namespace {{packageName}}.Client } } - if(!_disableHandlerFeatures) + if (_httpClientHandler != null && response != null) { - if (response != null) - { - try { - foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri)) - { - transformed.Cookies.Add(cookie); - } + try { + foreach (Cookie cookie in _httpClientHandler.CookieContainer.GetCookies(uri)) + { + transformed.Cookies.Add(cookie); } - catch (PlatformNotSupportedException) {} } + catch (PlatformNotSupportedException) {} } return transformed; @@ -431,8 +476,6 @@ namespace {{packageName}}.Client IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - var handler = _httpClientHandler; - var client = _httpClient; var deserializer = new CustomJsonCodec(SerializerSettings, configuration); var finalToken = cancellationToken; @@ -442,29 +485,31 @@ namespace {{packageName}}.Client var tokenSource = new CancellationTokenSource(configuration.Timeout); finalToken = CancellationTokenSource.CreateLinkedTokenSource(finalToken, tokenSource.Token).Token; } - if(!_disableHandlerFeatures) { - if (configuration.Proxy != null) - { - handler.Proxy = configuration.Proxy; - } - if (configuration.ClientCertificates != null) - { - handler.ClientCertificates.AddRange(configuration.ClientCertificates); - } + if (configuration.Proxy != null) + { + if(_httpClientHandler == null) throw new InvalidOperationException("Configuration `Proxy` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); + _httpClientHandler.Proxy = configuration.Proxy; + } + + if (configuration.ClientCertificates != null) + { + if(_httpClientHandler == null) throw new InvalidOperationException("Configuration `ClientCertificates` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); + _httpClientHandler.ClientCertificates.AddRange(configuration.ClientCertificates); } var cookieContainer = req.Properties.ContainsKey("CookieContainer") ? req.Properties["CookieContainer"] as List : null; if (cookieContainer != null) { + if(_httpClientHandler == null) throw new InvalidOperationException("Request property `CookieContainer` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); foreach (var cookie in cookieContainer) { - handler.CookieContainer.Add(cookie); + _httpClientHandler.CookieContainer.Add(cookie); } } - InterceptRequest(req, handler); + InterceptRequest(req); HttpResponseMessage response; {{#supportsRetry}} @@ -472,7 +517,7 @@ namespace {{packageName}}.Client { var policy = RetryConfiguration.AsyncRetryPolicy; var policyResult = await policy - .ExecuteAndCaptureAsync(() => client.SendAsync(req, cancellationToken)) + .ExecuteAndCaptureAsync(() => _httpClient.SendAsync(req, cancellationToken)) .ConfigureAwait(false); response = (policyResult.Outcome == OutcomeType.Successful) ? policyResult.Result : new HttpResponseMessage() @@ -484,7 +529,7 @@ namespace {{packageName}}.Client else { {{/supportsRetry}} - response = await client.SendAsync(req, cancellationToken).ConfigureAwait(false); + response = await _httpClient.SendAsync(req, cancellationToken).ConfigureAwait(false); {{#supportsRetry}} } {{/supportsRetry}} @@ -503,7 +548,7 @@ namespace {{packageName}}.Client InterceptResponse(req, response); - var result = ToApiResponse(response, responseData, handler, req.RequestUri); + var result = ToApiResponse(response, responseData, req.RequestUri); return result; } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index 4bb08fb6820..b71ebee0f81 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -107,29 +107,24 @@ namespace {{packageName}}.{{apiPackage}} /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public {{classname}}(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public {{classname}}() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public {{classname}}(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public {{classname}}(String basePath) { this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( {{packageName}}.Client.GlobalConfiguration.Instance, new {{packageName}}.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; {{#supportsAsync}} this.AsynchronousClient = this.ApiClient; @@ -138,15 +133,12 @@ namespace {{packageName}}.{{apiPackage}} } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public {{classname}}({{packageName}}.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public {{classname}}({{packageName}}.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -154,7 +146,140 @@ namespace {{packageName}}.{{apiPackage}} {{packageName}}.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + {{#supportsAsync}} + this.AsynchronousClient = this.ApiClient; + {{/supportsAsync}} + ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public {{classname}}(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public {{classname}}(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( + {{packageName}}.Client.GlobalConfiguration.Instance, + new {{packageName}}.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + {{#supportsAsync}} + this.AsynchronousClient = this.ApiClient; + {{/supportsAsync}} + this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public {{classname}}(HttpClient client, {{packageName}}.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( + {{packageName}}.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + {{#supportsAsync}} + this.AsynchronousClient = this.ApiClient; + {{/supportsAsync}} + ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public {{classname}}(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public {{classname}}(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( + {{packageName}}.Client.GlobalConfiguration.Instance, + new {{packageName}}.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + {{#supportsAsync}} + this.AsynchronousClient = this.ApiClient; + {{/supportsAsync}} + this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public {{classname}}(HttpClient client, HttpClientHandler handler, {{packageName}}.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( + {{packageName}}.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; {{#supportsAsync}} this.AsynchronousClient = this.ApiClient; @@ -169,6 +294,7 @@ namespace {{packageName}}.{{apiPackage}} /// The client interface for synchronous API access.{{#supportsAsync}} /// The client interface for asynchronous API access.{{/supportsAsync}} /// The configuration object. + /// public {{classname}}({{packageName}}.Client.ISynchronousClient client, {{#supportsAsync}}{{packageName}}.Client.IAsynchronousClient asyncClient, {{/supportsAsync}}{{packageName}}.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index ff1567b9aa5..e16da183ea8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -50,7 +50,10 @@ webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials; c.Proxy = webProxy; ``` -To use your own HttpClient instances just pass them to the ApiClass constructor. +### Connections +Each ApiClass (properly the ApiClient inside it) will create an istance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method. + +To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHander (see [here](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net) for details). To use your own HttpClient instance just pass it to the ApiClass constructor. ```csharp HttpClientHandler yourHandler = new HttpClientHandler(); @@ -58,17 +61,20 @@ HttpClient yourHttpClient = new HttpClient(yourHandler); var api = new YourApiClass(yourHttpClient, yourHandler); ``` -If you want to use an HttpClient and don't have access to the handler, for example in a DI context in aspnetcore when -using IHttpClientFactory. You need to disable the features that require handler access: +If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory. ```csharp HttpClient yourHttpClient = new HttpClient(); -var api = new YourApiClass(yourHttpClient, null, true); +var api = new YourApiClass(yourHttpClient); ``` +You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available. -The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. -You need to either manually handle those in your setup of the HttpClient or they won't be available. +Here an example of DI setup in a sample web project: +```csharp +services.AddHttpClient(httpClient => + new PetApi(httpClient)); +``` diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 58e3683c24e..6ee69d73cd3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -101,44 +101,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public AnotherFakeApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public AnotherFakeApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public AnotherFakeApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public AnotherFakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -146,7 +138,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public AnotherFakeApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public AnotherFakeApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public AnotherFakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public AnotherFakeApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public AnotherFakeApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public AnotherFakeApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -159,6 +276,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public AnotherFakeApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index c9d39aec22a..f79f629815a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -94,44 +94,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public DefaultApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public DefaultApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public DefaultApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public DefaultApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public DefaultApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public DefaultApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -139,7 +131,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public DefaultApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public DefaultApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public DefaultApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public DefaultApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public DefaultApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public DefaultApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -152,6 +269,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public DefaultApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index 22fd5bf56e6..96d3df634d2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -818,44 +818,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public FakeApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public FakeApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public FakeApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public FakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public FakeApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public FakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -863,7 +855,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public FakeApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public FakeApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public FakeApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -876,6 +993,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public FakeApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 413e4dc0886..1aa57d4b4e2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -101,44 +101,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public FakeClassnameTags123Api(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public FakeClassnameTags123Api() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public FakeClassnameTags123Api(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public FakeClassnameTags123Api(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -146,7 +138,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeClassnameTags123Api(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeClassnameTags123Api(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public FakeClassnameTags123Api(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -159,6 +276,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public FakeClassnameTags123Api(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index 2857ea58fef..ab82da44ef0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -463,44 +463,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public PetApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public PetApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public PetApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public PetApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public PetApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public PetApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -508,7 +500,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public PetApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public PetApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public PetApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public PetApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public PetApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public PetApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -521,6 +638,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public PetApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index b2ac30bcb54..760576e1ec0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -226,44 +226,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public StoreApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public StoreApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public StoreApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public StoreApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public StoreApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public StoreApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -271,7 +263,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public StoreApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public StoreApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public StoreApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public StoreApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public StoreApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public StoreApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -284,6 +401,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public StoreApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index 3a6c2619d01..c1174daeadf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -398,44 +398,36 @@ namespace Org.OpenAPITools.Api /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public UserApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures) + public UserApi() : this((string)null) { - } /// /// Initializes a new instance of the class. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// The target service's base path in URL format. + /// /// - public UserApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public UserApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; } /// - /// Initializes a new instance of the class - /// using Configuration object + /// Initializes a new instance of the class using Configuration object. /// - /// An instance of Configuration - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler + /// An instance of Configuration. + /// /// - public UserApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) + public UserApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -443,7 +435,132 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public UserApi(HttpClient client) : this(client, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public UserApi(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public UserApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + /// + public UserApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + public UserApi(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + new Org.OpenAPITools.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// An instance of Configuration. + /// + /// + public UserApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + if (handler == null) throw new ArgumentNullException("handler"); + + this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( + Org.OpenAPITools.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -456,6 +573,7 @@ namespace Org.OpenAPITools.Api /// The client interface for synchronous API access. /// The client interface for asynchronous API access. /// The configuration object. + /// public UserApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration) { if (client == null) throw new ArgumentNullException("client"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs index 12c007bdb9f..6cf20d59443 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -161,16 +161,16 @@ namespace Org.OpenAPITools.Client /// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios), /// encapsulating general REST accessor use cases. /// + /// + /// The Dispose method will manage the HttpClient lifecycle when not passed by constructor. + /// public partial class ApiClient : IDisposable, ISynchronousClient, IAsynchronousClient { private readonly String _baseUrl; - private readonly HttpClientHandler _httpClientHandler; - private readonly bool _disposeHandler; - private readonly HttpClient _httpClient; - private readonly bool _disposeClient; - - private readonly bool _disableHandlerFeatures; + private readonly HttpClientHandler _httpClientHandler; + private readonly HttpClient _httpClient; + private readonly bool _disposeClient; /// /// Specifies the settings on a object. @@ -192,37 +192,88 @@ namespace Org.OpenAPITools.Client /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler - public ApiClient(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : - this(Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath, client, handler, disableHandlerFeatures) - { + public ApiClient() : + this(Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) + { } - + /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// /// The target service's base path in URL format. - /// An instance of HttpClient - /// An instance of HttpClientHandler that is used by HttpClient - /// Disable ApiClient features that require access to the HttpClientHandler /// - public ApiClient(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) - { - if (string.IsNullOrEmpty(basePath)) - throw new ArgumentException("basePath cannot be empty"); + public ApiClient(String basePath) + { + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - _baseUrl = basePath; - if((client != null && handler == null) && !disableHandlerFeatures) { - throw new ArgumentException("If providing HttpClient, you also need to provide its handler or disable features requiring the handler, see README.md"); - } - - _disableHandlerFeatures = disableHandlerFeatures; - _httpClientHandler = handler ?? new HttpClientHandler(); - _disposeHandler = handler == null; - _httpClient = client ?? new HttpClient(_httpClientHandler, false); - _disposeClient = client == null; + _httpClientHandler = new HttpClientHandler(); + _httpClient = new HttpClient(_httpClientHandler, true); + _disposeClient = true; + _baseUrl = basePath; + } + + /// + /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// + /// An instance of HttpClient. + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client) : + this(client, Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) + { + } + + /// + /// Initializes a new instance of the + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, String basePath) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClient = client; + _baseUrl = basePath; + } + + /// + /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// + public ApiClient(HttpClient client, HttpClientHandler handler) : + this(client, handler, Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) + { + } + + /// + /// Initializes a new instance of the . + /// + /// An instance of HttpClient. + /// An instance of HttpClientHandler that is used by HttpClient. + /// The target service's base path in URL format. + /// + /// + public ApiClient(HttpClient client, HttpClientHandler handler, String basePath) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (handler == null) throw new ArgumentNullException("handler cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClientHandler = handler; + _httpClient = client; + _baseUrl = basePath; } /// @@ -233,9 +284,6 @@ namespace Org.OpenAPITools.Client if(_disposeClient) { _httpClient.Dispose(); } - if(_disposeHandler) { - _httpClientHandler.Dispose(); - } } /// Prepares multipart/form-data content @@ -371,10 +419,10 @@ namespace Org.OpenAPITools.Client return request; } - partial void InterceptRequest(HttpRequestMessage req, HttpClientHandler handler); + partial void InterceptRequest(HttpRequestMessage req); partial void InterceptResponse(HttpRequestMessage req, HttpResponseMessage response); - private ApiResponse ToApiResponse(HttpResponseMessage response, object responseData, HttpClientHandler handler, Uri uri) + private ApiResponse ToApiResponse(HttpResponseMessage response, object responseData, Uri uri) { T result = (T) responseData; string rawContent = response.Content.ToString(); @@ -403,18 +451,15 @@ namespace Org.OpenAPITools.Client } } - if(!_disableHandlerFeatures) + if (_httpClientHandler != null && response != null) { - if (response != null) - { - try { - foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri)) - { - transformed.Cookies.Add(cookie); - } + try { + foreach (Cookie cookie in _httpClientHandler.CookieContainer.GetCookies(uri)) + { + transformed.Cookies.Add(cookie); } - catch (PlatformNotSupportedException) {} } + catch (PlatformNotSupportedException) {} } return transformed; @@ -429,8 +474,6 @@ namespace Org.OpenAPITools.Client IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - var handler = _httpClientHandler; - var client = _httpClient; var deserializer = new CustomJsonCodec(SerializerSettings, configuration); var finalToken = cancellationToken; @@ -440,36 +483,38 @@ namespace Org.OpenAPITools.Client var tokenSource = new CancellationTokenSource(configuration.Timeout); finalToken = CancellationTokenSource.CreateLinkedTokenSource(finalToken, tokenSource.Token).Token; } - if(!_disableHandlerFeatures) { - if (configuration.Proxy != null) - { - handler.Proxy = configuration.Proxy; - } - if (configuration.ClientCertificates != null) - { - handler.ClientCertificates.AddRange(configuration.ClientCertificates); - } + if (configuration.Proxy != null) + { + if(_httpClientHandler == null) throw new InvalidOperationException("Configuration `Proxy` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); + _httpClientHandler.Proxy = configuration.Proxy; + } + + if (configuration.ClientCertificates != null) + { + if(_httpClientHandler == null) throw new InvalidOperationException("Configuration `ClientCertificates` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); + _httpClientHandler.ClientCertificates.AddRange(configuration.ClientCertificates); } var cookieContainer = req.Properties.ContainsKey("CookieContainer") ? req.Properties["CookieContainer"] as List : null; if (cookieContainer != null) { + if(_httpClientHandler == null) throw new InvalidOperationException("Request property `CookieContainer` not supported when the client is explicitly created without an HttpClientHandler, use the proper constructor."); foreach (var cookie in cookieContainer) { - handler.CookieContainer.Add(cookie); + _httpClientHandler.CookieContainer.Add(cookie); } } - InterceptRequest(req, handler); + InterceptRequest(req); HttpResponseMessage response; if (RetryConfiguration.AsyncRetryPolicy != null) { var policy = RetryConfiguration.AsyncRetryPolicy; var policyResult = await policy - .ExecuteAndCaptureAsync(() => client.SendAsync(req, cancellationToken)) + .ExecuteAndCaptureAsync(() => _httpClient.SendAsync(req, cancellationToken)) .ConfigureAwait(false); response = (policyResult.Outcome == OutcomeType.Successful) ? policyResult.Result : new HttpResponseMessage() @@ -480,7 +525,7 @@ namespace Org.OpenAPITools.Client } else { - response = await client.SendAsync(req, cancellationToken).ConfigureAwait(false); + response = await _httpClient.SendAsync(req, cancellationToken).ConfigureAwait(false); } object responseData = deserializer.Deserialize(response); @@ -497,7 +542,7 @@ namespace Org.OpenAPITools.Client InterceptResponse(req, response); - var result = ToApiResponse(response, responseData, handler, req.RequestUri); + var result = ToApiResponse(response, responseData, req.RequestUri); return result; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md index 8d4de67b2fb..d4c69a74426 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md @@ -29,7 +29,8 @@ Install-Package System.ComponentModel.Annotations Install-Package CompareNETObjects ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742). +NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406). ## Installation diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md index 8d4de67b2fb..d4c69a74426 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md @@ -29,7 +29,8 @@ Install-Package System.ComponentModel.Annotations Install-Package CompareNETObjects ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742). +NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406). ## Installation diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md index cec8c29dbba..325ba2bd65b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md @@ -32,7 +32,8 @@ Install-Package System.ComponentModel.Annotations Install-Package CompareNETObjects ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742). +NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406). ## Installation diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md index 8d4de67b2fb..d4c69a74426 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md @@ -29,7 +29,8 @@ Install-Package System.ComponentModel.Annotations Install-Package CompareNETObjects ``` -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742). +NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406). ## Installation From de5651adac3fd0fc9609a1668bcd70315db7e4f0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 31 Mar 2021 15:11:10 +0800 Subject: [PATCH 03/99] [C#] fix integer enum without format (#9136) * fix inner enum integer without format * add line break, update samples * remove line break * add line break * update SHA --- bin/utils/test_file_list.yaml | 2 +- .../languages/AbstractCSharpCodegen.java | 2 +- .../csharp-netcore/modelGeneric.mustache | 1 + ...odels-for-testing-with-http-signature.yaml | 5 ++ .../OpenAPIClient-httpclient/docs/EnumTest.md | 1 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 1 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 1 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 37 +++++++++- .../src/Org.OpenAPITools/Model/MapTest.cs | 1 + .../src/Org.OpenAPITools/Model/Order.cs | 1 + .../src/Org.OpenAPITools/Model/Pet.cs | 1 + .../src/Org.OpenAPITools/Model/Zebra.cs | 1 + .../OpenAPIClient-net47/docs/EnumTest.md | 1 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 1 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 1 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 37 +++++++++- .../src/Org.OpenAPITools/Model/MapTest.cs | 1 + .../src/Org.OpenAPITools/Model/Order.cs | 1 + .../src/Org.OpenAPITools/Model/Pet.cs | 1 + .../src/Org.OpenAPITools/Model/Zebra.cs | 1 + .../OpenAPIClient-net5.0/docs/EnumTest.md | 1 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 1 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 1 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 37 +++++++++- .../src/Org.OpenAPITools/Model/MapTest.cs | 1 + .../src/Org.OpenAPITools/Model/Order.cs | 1 + .../src/Org.OpenAPITools/Model/Pet.cs | 1 + .../src/Org.OpenAPITools/Model/Zebra.cs | 1 + .../OpenAPIClient/docs/EnumTest.md | 1 + .../JSONComposedSchemaTests.cs | 12 ++++ .../src/Org.OpenAPITools/Model/ChildCat.cs | 1 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 1 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 37 +++++++++- .../src/Org.OpenAPITools/Model/MapTest.cs | 1 + .../src/Org.OpenAPITools/Model/Order.cs | 1 + .../src/Org.OpenAPITools/Model/Pet.cs | 1 + .../src/Org.OpenAPITools/Model/Zebra.cs | 1 + .../OpenAPIClientCore/docs/EnumTest.md | 1 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 1 + .../Org.OpenAPITools/Model/ChildCatAllOf.cs | 1 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 2 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 37 +++++++++- .../src/Org.OpenAPITools/Model/MapTest.cs | 1 + .../src/Org.OpenAPITools/Model/Order.cs | 1 + .../src/Org.OpenAPITools/Model/Pet.cs | 1 + .../src/Org.OpenAPITools/Model/Zebra.cs | 1 + .../java/jersey2-java8/api/openapi.yaml | 5 ++ .../java/jersey2-java8/docs/EnumTest.md | 10 +++ .../openapitools/client/model/EnumTest.java | 69 ++++++++++++++++++- .../petstore/java/native/api/openapi.yaml | 5 ++ .../petstore/java/native/docs/EnumTest.md | 10 +++ .../openapitools/client/model/EnumTest.java | 69 ++++++++++++++++++- 56 files changed, 411 insertions(+), 9 deletions(-) diff --git a/bin/utils/test_file_list.yaml b/bin/utils/test_file_list.yaml index 9d55e425058..286c876104e 100644 --- a/bin/utils/test_file_list.yaml +++ b/bin/utils/test_file_list.yaml @@ -1,7 +1,7 @@ --- # csharp-netcore test files and image for upload - filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs" - sha256: ec34838fbbb1abb9f762949d510503b6237b607400a85c848c234c39d013a776 + sha256: 95e40cace36e7cd1608fa494161f06291f4cfb8f859ec4196ae9939f520b152a - filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs" sha256: dae985015ba461297927d544a78267f2def35e07c3f14ca66468fd61e1fd1c26 - filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png" diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index 2782357482c..eb263b34c37 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -576,7 +576,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co var.isString = false; var.isLong = false; var.isInteger = false; - } else if ("int32".equals(var.dataFormat)) { + } else if ("int".equals(var.dataType) || "int32".equals(var.dataFormat)) { var.isInteger = true; var.isString = false; var.isLong = false; diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache index c3333605694..3ecfa611d68 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache @@ -24,6 +24,7 @@ {{/complexType}} {{/isEnum}} {{#isEnum}} + /// /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} /// diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 05b1c7abd35..08ba51d46d0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1546,6 +1546,11 @@ components: enum: - 1 - -1 + enum_integer_only: + type: integer + enum: + - 2 + - -2 enum_number: type: number format: double diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/EnumTest.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/EnumTest.md index ac0ae4e6a8e..5ce3c4addd9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/EnumTest.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/EnumTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **EnumString** | **string** | | [optional] **EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **OuterEnum** | **OuterEnum** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs index 8c2d77ca45d..e883d3d20bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs @@ -48,6 +48,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index a8a0e05b660..36268a8093a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs index 8befbb0b504..be9b0c5e801 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -52,6 +52,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets JustSymbol /// @@ -78,6 +79,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets ArrayEnum /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs index 233087cc170..c9c56e18386 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/EnumTest.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumString /// @@ -89,6 +90,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumStringRequired /// @@ -111,12 +113,36 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumInteger /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + + } + + + /// + /// Gets or Sets EnumIntegerOnly + /// + [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// [JsonConverter(typeof(StringEnumConverter))] @@ -136,26 +162,31 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumNumber /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// @@ -175,16 +206,18 @@ namespace Org.OpenAPITools.Model /// enumString. /// enumStringRequired (required). /// enumInteger. + /// enumIntegerOnly. /// enumNumber. /// outerEnum. /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) { this.EnumStringRequired = enumStringRequired; this.EnumString = enumString; this.EnumInteger = enumInteger; + this.EnumIntegerOnly = enumIntegerOnly; this.EnumNumber = enumNumber; this.OuterEnum = outerEnum; this.OuterEnumInteger = outerEnumInteger; @@ -210,6 +243,7 @@ namespace Org.OpenAPITools.Model sb.Append(" EnumString: ").Append(EnumString).Append("\n"); sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); @@ -261,6 +295,7 @@ namespace Org.OpenAPITools.Model hashCode = hashCode * 59 + this.EnumString.GetHashCode(); hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode(); hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs index 0f9e49a98b3..b88cfef72c1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MapTest.cs @@ -53,6 +53,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets MapOfEnumString /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs index 6b572bfef78..4f327640915 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Order.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// Order Status /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs index 4f7057df98d..db3cdd72606 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pet.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// pet status in the store /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1ac..cfa92d1b708 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Zebra.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets Type /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/EnumTest.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/EnumTest.md index ac0ae4e6a8e..5ce3c4addd9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/EnumTest.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/EnumTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **EnumString** | **string** | | [optional] **EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **OuterEnum** | **OuterEnum** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs index 8c2d77ca45d..e883d3d20bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs @@ -48,6 +48,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index a8a0e05b660..36268a8093a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumArrays.cs index 8befbb0b504..be9b0c5e801 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -52,6 +52,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets JustSymbol /// @@ -78,6 +79,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets ArrayEnum /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumTest.cs index 233087cc170..c9c56e18386 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/EnumTest.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumString /// @@ -89,6 +90,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumStringRequired /// @@ -111,12 +113,36 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumInteger /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + + } + + + /// + /// Gets or Sets EnumIntegerOnly + /// + [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// [JsonConverter(typeof(StringEnumConverter))] @@ -136,26 +162,31 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumNumber /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// @@ -175,16 +206,18 @@ namespace Org.OpenAPITools.Model /// enumString. /// enumStringRequired (required). /// enumInteger. + /// enumIntegerOnly. /// enumNumber. /// outerEnum. /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) { this.EnumStringRequired = enumStringRequired; this.EnumString = enumString; this.EnumInteger = enumInteger; + this.EnumIntegerOnly = enumIntegerOnly; this.EnumNumber = enumNumber; this.OuterEnum = outerEnum; this.OuterEnumInteger = outerEnumInteger; @@ -210,6 +243,7 @@ namespace Org.OpenAPITools.Model sb.Append(" EnumString: ").Append(EnumString).Append("\n"); sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); @@ -261,6 +295,7 @@ namespace Org.OpenAPITools.Model hashCode = hashCode * 59 + this.EnumString.GetHashCode(); hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode(); hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MapTest.cs index 0f9e49a98b3..b88cfef72c1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MapTest.cs @@ -53,6 +53,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets MapOfEnumString /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Order.cs index 6b572bfef78..4f327640915 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Order.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// Order Status /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pet.cs index 4f7057df98d..db3cdd72606 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pet.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// pet status in the store /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1ac..cfa92d1b708 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Zebra.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets Type /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/EnumTest.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/EnumTest.md index ac0ae4e6a8e..5ce3c4addd9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/EnumTest.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/EnumTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **EnumString** | **string** | | [optional] **EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **OuterEnum** | **OuterEnum** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs index 8c2d77ca45d..e883d3d20bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs @@ -48,6 +48,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index a8a0e05b660..36268a8093a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumArrays.cs index 8befbb0b504..be9b0c5e801 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -52,6 +52,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets JustSymbol /// @@ -78,6 +79,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets ArrayEnum /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumTest.cs index 233087cc170..c9c56e18386 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/EnumTest.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumString /// @@ -89,6 +90,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumStringRequired /// @@ -111,12 +113,36 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumInteger /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + + } + + + /// + /// Gets or Sets EnumIntegerOnly + /// + [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// [JsonConverter(typeof(StringEnumConverter))] @@ -136,26 +162,31 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumNumber /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// @@ -175,16 +206,18 @@ namespace Org.OpenAPITools.Model /// enumString. /// enumStringRequired (required). /// enumInteger. + /// enumIntegerOnly. /// enumNumber. /// outerEnum. /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) { this.EnumStringRequired = enumStringRequired; this.EnumString = enumString; this.EnumInteger = enumInteger; + this.EnumIntegerOnly = enumIntegerOnly; this.EnumNumber = enumNumber; this.OuterEnum = outerEnum; this.OuterEnumInteger = outerEnumInteger; @@ -210,6 +243,7 @@ namespace Org.OpenAPITools.Model sb.Append(" EnumString: ").Append(EnumString).Append("\n"); sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); @@ -261,6 +295,7 @@ namespace Org.OpenAPITools.Model hashCode = hashCode * 59 + this.EnumString.GetHashCode(); hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode(); hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MapTest.cs index 0f9e49a98b3..b88cfef72c1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MapTest.cs @@ -53,6 +53,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets MapOfEnumString /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Order.cs index 6b572bfef78..4f327640915 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Order.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// Order Status /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pet.cs index 4f7057df98d..db3cdd72606 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pet.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// pet status in the store /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1ac..cfa92d1b708 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Zebra.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets Type /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/EnumTest.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/EnumTest.md index ac0ae4e6a8e..5ce3c4addd9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/EnumTest.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/EnumTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **EnumString** | **string** | | [optional] **EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **OuterEnum** | **OuterEnum** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs index 9a5f17e0431..e9478032ece 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs @@ -171,5 +171,17 @@ namespace Org.OpenAPITools.Test OuterEnumInteger instance = OuterEnumInteger.NUMBER_1; Assert.Equal(1, (int)instance); } + + /// + /// Test inner enum integer + /// + [Fact] + public void InnerEnumIntegerInstanceTest() + { + EnumTest enumTest = new EnumTest(); + enumTest.EnumIntegerOnly = EnumTest.EnumIntegerOnlyEnum.NUMBER_2; + enumTest.EnumInteger = EnumTest.EnumIntegerEnum.NUMBER_MINUS_1; + Assert.Equal("{\"enum_integer\":-1,\"enum_integer_only\":2,\"outerEnum\":null}", JsonConvert.SerializeObject(enumTest)); + } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs index 8c2d77ca45d..e883d3d20bb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs @@ -48,6 +48,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index a8a0e05b660..36268a8093a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumArrays.cs index 8befbb0b504..be9b0c5e801 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -52,6 +52,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets JustSymbol /// @@ -78,6 +79,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets ArrayEnum /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumTest.cs index 233087cc170..c9c56e18386 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/EnumTest.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumString /// @@ -89,6 +90,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumStringRequired /// @@ -111,12 +113,36 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumInteger /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + + } + + + /// + /// Gets or Sets EnumIntegerOnly + /// + [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// [JsonConverter(typeof(StringEnumConverter))] @@ -136,26 +162,31 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumNumber /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// @@ -175,16 +206,18 @@ namespace Org.OpenAPITools.Model /// enumString. /// enumStringRequired (required). /// enumInteger. + /// enumIntegerOnly. /// enumNumber. /// outerEnum. /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) { this.EnumStringRequired = enumStringRequired; this.EnumString = enumString; this.EnumInteger = enumInteger; + this.EnumIntegerOnly = enumIntegerOnly; this.EnumNumber = enumNumber; this.OuterEnum = outerEnum; this.OuterEnumInteger = outerEnumInteger; @@ -210,6 +243,7 @@ namespace Org.OpenAPITools.Model sb.Append(" EnumString: ").Append(EnumString).Append("\n"); sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); @@ -261,6 +295,7 @@ namespace Org.OpenAPITools.Model hashCode = hashCode * 59 + this.EnumString.GetHashCode(); hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode(); hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/MapTest.cs index 0f9e49a98b3..b88cfef72c1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/MapTest.cs @@ -53,6 +53,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets MapOfEnumString /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Order.cs index 6b572bfef78..4f327640915 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Order.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// Order Status /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Pet.cs index 4f7057df98d..db3cdd72606 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Pet.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// pet status in the store /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1ac..cfa92d1b708 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Zebra.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets Type /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/EnumTest.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/EnumTest.md index ac0ae4e6a8e..5ce3c4addd9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/EnumTest.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/EnumTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **EnumString** | **string** | | [optional] **EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **OuterEnum** | **OuterEnum** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs index 8070a78eddb..bcf4c51cc11 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs @@ -48,6 +48,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index 4c6970f2e86..4c1be85c780 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets PetType /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumArrays.cs index 973bcd57d84..d92ef28bc12 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -52,6 +52,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets JustSymbol /// @@ -78,6 +79,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets ArrayEnum /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumTest.cs index 3909f157561..552d85e65e5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/EnumTest.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumString /// @@ -89,6 +90,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumStringRequired /// @@ -111,12 +113,36 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumInteger /// [DataMember(Name = "enum_integer", EmitDefaultValue = false)] public EnumIntegerEnum? EnumInteger { get; set; } /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + + } + + + /// + /// Gets or Sets EnumIntegerOnly + /// + [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// [JsonConverter(typeof(StringEnumConverter))] @@ -136,26 +162,31 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets EnumNumber /// [DataMember(Name = "enum_number", EmitDefaultValue = false)] public EnumNumberEnum? EnumNumber { get; set; } + /// /// Gets or Sets OuterEnum /// [DataMember(Name = "outerEnum", EmitDefaultValue = true)] public OuterEnum? OuterEnum { get; set; } + /// /// Gets or Sets OuterEnumInteger /// [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] public OuterEnumInteger? OuterEnumInteger { get; set; } + /// /// Gets or Sets OuterEnumDefaultValue /// [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// @@ -172,16 +203,18 @@ namespace Org.OpenAPITools.Model /// enumString. /// enumStringRequired (required). /// enumInteger. + /// enumIntegerOnly. /// enumNumber. /// outerEnum. /// outerEnumInteger. /// outerEnumDefaultValue. /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) + public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?)) { this.EnumStringRequired = enumStringRequired; this.EnumString = enumString; this.EnumInteger = enumInteger; + this.EnumIntegerOnly = enumIntegerOnly; this.EnumNumber = enumNumber; this.OuterEnum = outerEnum; this.OuterEnumInteger = outerEnumInteger; @@ -200,6 +233,7 @@ namespace Org.OpenAPITools.Model sb.Append(" EnumString: ").Append(EnumString).Append("\n"); sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); @@ -250,6 +284,7 @@ namespace Org.OpenAPITools.Model hashCode = hashCode * 59 + this.EnumString.GetHashCode(); hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode(); hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode(); hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/MapTest.cs index 1f59479c64c..5e73fbc7530 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/MapTest.cs @@ -53,6 +53,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets MapOfEnumString /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Order.cs index 7f1cf4b8492..185dbedf872 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Order.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// Order Status /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pet.cs index e57ddf37711..6e72b768fb0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pet.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model } + /// /// pet status in the store /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Zebra.cs index cd2f85fe1ac..cfa92d1b708 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/Zebra.cs @@ -58,6 +58,7 @@ namespace Org.OpenAPITools.Model } + /// /// Gets or Sets Type /// diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml b/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml index 0ef965969a7..a1946fa60c0 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml +++ b/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml @@ -1689,6 +1689,11 @@ components: - -1 format: int32 type: integer + enum_integer_only: + enum: + - 2 + - -2 + type: integer enum_number: enum: - 1.1 diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/EnumTest.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/EnumTest.md index 87f1158ba26..342b462ccc0 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/EnumTest.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional] **enumStringRequired** | [**EnumStringRequiredEnum**](#EnumStringRequiredEnum) | | **enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional] +**enumIntegerOnly** | [**EnumIntegerOnlyEnum**](#EnumIntegerOnlyEnum) | | [optional] **enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional] **outerEnum** | **OuterEnum** | | [optional] **outerEnumInteger** | **OuterEnumInteger** | | [optional] @@ -47,6 +48,15 @@ NUMBER_MINUS_1 | -1 +## Enum: EnumIntegerOnlyEnum + +Name | Value +---- | ----- +NUMBER_2 | 2 +NUMBER_MINUS_2 | -2 + + + ## Enum: EnumNumberEnum Name | Value diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java index 34a92c6d98f..d21e23726d8 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java @@ -42,6 +42,7 @@ import org.openapitools.client.JSON; EnumTest.JSON_PROPERTY_ENUM_STRING, EnumTest.JSON_PROPERTY_ENUM_STRING_REQUIRED, EnumTest.JSON_PROPERTY_ENUM_INTEGER, + EnumTest.JSON_PROPERTY_ENUM_INTEGER_ONLY, EnumTest.JSON_PROPERTY_ENUM_NUMBER, EnumTest.JSON_PROPERTY_OUTER_ENUM, EnumTest.JSON_PROPERTY_OUTER_ENUM_INTEGER, @@ -168,6 +169,44 @@ public class EnumTest { public static final String JSON_PROPERTY_ENUM_INTEGER = "enum_integer"; private EnumIntegerEnum enumInteger; + /** + * Gets or Sets enumIntegerOnly + */ + public enum EnumIntegerOnlyEnum { + NUMBER_2(2), + + NUMBER_MINUS_2(-2); + + private Integer value; + + EnumIntegerOnlyEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerOnlyEnum fromValue(Integer value) { + for (EnumIntegerOnlyEnum b : EnumIntegerOnlyEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_ENUM_INTEGER_ONLY = "enum_integer_only"; + private EnumIntegerOnlyEnum enumIntegerOnly; + /** * Gets or Sets enumNumber */ @@ -296,6 +335,32 @@ public class EnumTest { } + public EnumTest enumIntegerOnly(EnumIntegerOnlyEnum enumIntegerOnly) { + this.enumIntegerOnly = enumIntegerOnly; + return this; + } + + /** + * Get enumIntegerOnly + * @return enumIntegerOnly + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ENUM_INTEGER_ONLY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public EnumIntegerOnlyEnum getEnumIntegerOnly() { + return enumIntegerOnly; + } + + + @JsonProperty(JSON_PROPERTY_ENUM_INTEGER_ONLY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEnumIntegerOnly(EnumIntegerOnlyEnum enumIntegerOnly) { + this.enumIntegerOnly = enumIntegerOnly; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { this.enumNumber = enumNumber; return this; @@ -449,6 +514,7 @@ public class EnumTest { return Objects.equals(this.enumString, enumTest.enumString) && Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumIntegerOnly, enumTest.enumIntegerOnly) && Objects.equals(this.enumNumber, enumTest.enumNumber) && Objects.equals(this.outerEnum, enumTest.outerEnum) && Objects.equals(this.outerEnumInteger, enumTest.outerEnumInteger) && @@ -458,7 +524,7 @@ public class EnumTest { @Override public int hashCode() { - return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum, outerEnumInteger, outerEnumDefaultValue, outerEnumIntegerDefaultValue); + return Objects.hash(enumString, enumStringRequired, enumInteger, enumIntegerOnly, enumNumber, outerEnum, outerEnumInteger, outerEnumDefaultValue, outerEnumIntegerDefaultValue); } @Override @@ -468,6 +534,7 @@ public class EnumTest { sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumIntegerOnly: ").append(toIndentedString(enumIntegerOnly)).append("\n"); sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); sb.append(" outerEnumInteger: ").append(toIndentedString(outerEnumInteger)).append("\n"); diff --git a/samples/openapi3/client/petstore/java/native/api/openapi.yaml b/samples/openapi3/client/petstore/java/native/api/openapi.yaml index 0ef965969a7..a1946fa60c0 100644 --- a/samples/openapi3/client/petstore/java/native/api/openapi.yaml +++ b/samples/openapi3/client/petstore/java/native/api/openapi.yaml @@ -1689,6 +1689,11 @@ components: - -1 format: int32 type: integer + enum_integer_only: + enum: + - 2 + - -2 + type: integer enum_number: enum: - 1.1 diff --git a/samples/openapi3/client/petstore/java/native/docs/EnumTest.md b/samples/openapi3/client/petstore/java/native/docs/EnumTest.md index 87f1158ba26..342b462ccc0 100644 --- a/samples/openapi3/client/petstore/java/native/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/java/native/docs/EnumTest.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional] **enumStringRequired** | [**EnumStringRequiredEnum**](#EnumStringRequiredEnum) | | **enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional] +**enumIntegerOnly** | [**EnumIntegerOnlyEnum**](#EnumIntegerOnlyEnum) | | [optional] **enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional] **outerEnum** | **OuterEnum** | | [optional] **outerEnumInteger** | **OuterEnumInteger** | | [optional] @@ -47,6 +48,15 @@ NUMBER_MINUS_1 | -1 +## Enum: EnumIntegerOnlyEnum + +Name | Value +---- | ----- +NUMBER_2 | 2 +NUMBER_MINUS_2 | -2 + + + ## Enum: EnumNumberEnum Name | Value diff --git a/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java index acb175acade..194c5e7f7a2 100644 --- a/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java @@ -41,6 +41,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; EnumTest.JSON_PROPERTY_ENUM_STRING, EnumTest.JSON_PROPERTY_ENUM_STRING_REQUIRED, EnumTest.JSON_PROPERTY_ENUM_INTEGER, + EnumTest.JSON_PROPERTY_ENUM_INTEGER_ONLY, EnumTest.JSON_PROPERTY_ENUM_NUMBER, EnumTest.JSON_PROPERTY_OUTER_ENUM, EnumTest.JSON_PROPERTY_OUTER_ENUM_INTEGER, @@ -167,6 +168,44 @@ public class EnumTest { public static final String JSON_PROPERTY_ENUM_INTEGER = "enum_integer"; private EnumIntegerEnum enumInteger; + /** + * Gets or Sets enumIntegerOnly + */ + public enum EnumIntegerOnlyEnum { + NUMBER_2(2), + + NUMBER_MINUS_2(-2); + + private Integer value; + + EnumIntegerOnlyEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerOnlyEnum fromValue(Integer value) { + for (EnumIntegerOnlyEnum b : EnumIntegerOnlyEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_ENUM_INTEGER_ONLY = "enum_integer_only"; + private EnumIntegerOnlyEnum enumIntegerOnly; + /** * Gets or Sets enumNumber */ @@ -295,6 +334,32 @@ public class EnumTest { } + public EnumTest enumIntegerOnly(EnumIntegerOnlyEnum enumIntegerOnly) { + this.enumIntegerOnly = enumIntegerOnly; + return this; + } + + /** + * Get enumIntegerOnly + * @return enumIntegerOnly + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ENUM_INTEGER_ONLY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public EnumIntegerOnlyEnum getEnumIntegerOnly() { + return enumIntegerOnly; + } + + + @JsonProperty(JSON_PROPERTY_ENUM_INTEGER_ONLY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEnumIntegerOnly(EnumIntegerOnlyEnum enumIntegerOnly) { + this.enumIntegerOnly = enumIntegerOnly; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { this.enumNumber = enumNumber; return this; @@ -448,6 +513,7 @@ public class EnumTest { return Objects.equals(this.enumString, enumTest.enumString) && Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumIntegerOnly, enumTest.enumIntegerOnly) && Objects.equals(this.enumNumber, enumTest.enumNumber) && Objects.equals(this.outerEnum, enumTest.outerEnum) && Objects.equals(this.outerEnumInteger, enumTest.outerEnumInteger) && @@ -457,7 +523,7 @@ public class EnumTest { @Override public int hashCode() { - return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum, outerEnumInteger, outerEnumDefaultValue, outerEnumIntegerDefaultValue); + return Objects.hash(enumString, enumStringRequired, enumInteger, enumIntegerOnly, enumNumber, outerEnum, outerEnumInteger, outerEnumDefaultValue, outerEnumIntegerDefaultValue); } @Override @@ -467,6 +533,7 @@ public class EnumTest { sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumIntegerOnly: ").append(toIndentedString(enumIntegerOnly)).append("\n"); sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); sb.append(" outerEnumInteger: ").append(toIndentedString(outerEnumInteger)).append("\n"); From 628e3d19144c1c08ce438240bf715051054054a4 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 31 Mar 2021 15:56:50 +0800 Subject: [PATCH 04/99] remove pthread (#9130) --- .../main/resources/cpp-rest-sdk-client/cmake-lists.mustache | 5 ++--- samples/client/petstore/cpp-restsdk/client/CMakeLists.txt | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache index 66171dc81a8..b882ea0e723 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache @@ -39,7 +39,6 @@ else() find_package(cpprestsdk REQUIRED) find_package(Boost REQUIRED) - find_package(pthreads REQUIRED) endif() # Manually set the cpprestsdk paths when not using package manager @@ -68,9 +67,9 @@ target_link_directories( ) if (UNIX) - target_link_libraries(${PROJECT_NAME} PRIVATE cpprest pthread ${Boost_LIBRARIES} crypto) + target_link_libraries(${PROJECT_NAME} PRIVATE cpprest ${Boost_LIBRARIES} crypto) else() - target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${pthreads_LIBRARIES} ${Boost_LIBRARIES} bcrypt) + target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt b/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt index 3275a2586ea..923a3f75752 100644 --- a/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt +++ b/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt @@ -39,7 +39,6 @@ else() find_package(cpprestsdk REQUIRED) find_package(Boost REQUIRED) - find_package(pthreads REQUIRED) endif() # Manually set the cpprestsdk paths when not using package manager @@ -68,9 +67,9 @@ target_link_directories( ) if (UNIX) - target_link_libraries(${PROJECT_NAME} PRIVATE cpprest pthread ${Boost_LIBRARIES} crypto) + target_link_libraries(${PROJECT_NAME} PRIVATE cpprest ${Boost_LIBRARIES} crypto) else() - target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${pthreads_LIBRARIES} ${Boost_LIBRARIES} bcrypt) + target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest ${Boost_LIBRARIES} bcrypt) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) From 47e292c0e76cc5ed29d7f5c3c64f000b0132376b Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 31 Mar 2021 10:45:47 +0200 Subject: [PATCH 05/99] [dart][dart-dio] Remove sample formatting from dart-dio-next (#9121) --- CI/circle_parallel.sh | 1 - ...art-dio-next-petstore-client-lib-fake.yaml | 1 - docs/file-post-processing.md | 1 - .../languages/AbstractDartCodegen.java | 29 -- .../petstore_client_lib_fake/lib/src/api.dart | 15 +- .../lib/src/api/another_fake_api.dart | 13 +- .../lib/src/api/default_api.dart | 12 +- .../lib/src/api/fake_api.dart | 253 +++++------ .../src/api/fake_classname_tags123_api.dart | 13 +- .../lib/src/api/pet_api.dart | 120 ++--- .../lib/src/api/store_api.dart | 41 +- .../lib/src/api/user_api.dart | 80 ++-- .../lib/src/api_util.dart | 3 +- .../lib/src/auth/api_key_auth.dart | 1 + .../lib/src/auth/basic_auth.dart | 3 +- .../model/additional_properties_class.dart | 129 +++--- .../lib/src/model/animal.dart | 102 +++-- .../lib/src/model/api_response.dart | 129 +++--- .../model/array_of_array_of_number_only.dart | 100 ++-- .../lib/src/model/array_of_number_only.dart | 91 ++-- .../lib/src/model/array_test.dart | 138 +++--- .../lib/src/model/capitalization.dart | 212 +++++---- .../lib/src/model/cat.dart | 124 ++--- .../lib/src/model/cat_all_of.dart | 81 ++-- .../lib/src/model/category.dart | 102 +++-- .../lib/src/model/class_model.dart | 81 ++-- .../lib/src/model/dog.dart | 124 ++--- .../lib/src/model/dog_all_of.dart | 81 ++-- .../lib/src/model/enum_arrays.dart | 143 +++--- .../lib/src/model/enum_test.dart | 337 +++++++------- .../lib/src/model/file_schema_test_class.dart | 120 +++-- .../lib/src/model/foo.dart | 82 ++-- .../lib/src/model/format_test.dart | 429 +++++++++--------- .../lib/src/model/has_only_read_only.dart | 114 +++-- .../lib/src/model/health_check_result.dart | 90 ++-- .../src/model/inline_response_default.dart | 94 ++-- .../lib/src/model/map_test.dart | 189 ++++---- ...rties_and_additional_properties_class.dart | 153 +++---- .../lib/src/model/model200_response.dart | 114 +++-- .../lib/src/model/model_client.dart | 81 ++-- .../lib/src/model/model_enum_class.dart | 10 +- .../lib/src/model/model_file.dart | 83 ++-- .../lib/src/model/model_list.dart | 81 ++-- .../lib/src/model/model_return.dart | 81 ++-- .../lib/src/model/name.dart | 149 +++--- .../lib/src/model/nullable_class.dart | 368 +++++++-------- .../lib/src/model/number_only.dart | 81 ++-- .../lib/src/model/order.dart | 215 ++++----- .../lib/src/model/outer_composite.dart | 138 +++--- .../lib/src/model/outer_enum.dart | 4 +- .../src/model/outer_enum_default_value.dart | 10 +- .../lib/src/model/outer_enum_integer.dart | 7 +- .../outer_enum_integer_default_value.dart | 10 +- .../outer_object_with_enum_property.dart | 101 ++--- .../lib/src/model/pet.dart | 204 ++++----- .../lib/src/model/read_only_first.dart | 111 +++-- .../lib/src/model/special_model_name.dart | 95 ++-- .../lib/src/model/tag.dart | 105 ++--- .../lib/src/model/user.dart | 251 +++++----- .../petstore_client_lib_fake/pom.xml | 12 +- 60 files changed, 3016 insertions(+), 3126 deletions(-) rename bin/configs/{other => }/dart-dio-next-petstore-client-lib-fake.yaml (92%) diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index b8d25329014..e66f5524256 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -23,7 +23,6 @@ function installDart { sudo apt-get update sudo apt-get install dart export PATH="$PATH:/usr/lib/dart/bin" - export DART_POST_PROCESS="dart format" } if [ "$NODE_INDEX" = "1" ]; then diff --git a/bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml b/bin/configs/dart-dio-next-petstore-client-lib-fake.yaml similarity index 92% rename from bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml rename to bin/configs/dart-dio-next-petstore-client-lib-fake.yaml index d6a85861a8a..830b10ebb75 100644 --- a/bin/configs/other/dart-dio-next-petstore-client-lib-fake.yaml +++ b/bin/configs/dart-dio-next-petstore-client-lib-fake.yaml @@ -2,6 +2,5 @@ generatorName: dart-dio-next outputDir: samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio -enablePostProcessFile: "true" additionalProperties: hideGenerationTimestamp: "true" diff --git a/docs/file-post-processing.md b/docs/file-post-processing.md index b0c66e28f8d..a23845adae2 100644 --- a/docs/file-post-processing.md +++ b/docs/file-post-processing.md @@ -22,7 +22,6 @@ The following environment variables are supported by their respective generators * `CPP_POST_PROCESS_FILE` * `CSHARP_POST_PROCESS_FILE` * `C_POST_PROCESS_FILE` -* `DART_POST_PROCESS` * `DART_POST_PROCESS_FILE` * `FSHARP_POST_PROCESS_FILE` * `GO_POST_PROCESS_FILE` diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java index 6f320377c52..65c6302987d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java @@ -692,33 +692,4 @@ public abstract class AbstractDartCodegen extends DefaultCodegen { } } } - - @Override - public void postProcess() { - if (isEnablePostProcessFile()) { - // Using the condition here to have way to still disable this - // for older Dart generators in CI by default. - - // Post processing the whole dart output is much faster then individual files. - // Setting this variable to "dart format" is the suggested way of doing this. - final String dartPostProcess = System.getenv("DART_POST_PROCESS"); - if (!StringUtils.isEmpty(dartPostProcess)) { - final String command = dartPostProcess + " " + getOutputDir(); - try { - Process p = Runtime.getRuntime().exec(command); - int exitValue = p.waitFor(); - if (exitValue != 0) { - LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue); - } else { - LOGGER.info("Successfully executed: {}", command); - } - } catch (InterruptedException | IOException e) { - LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); - // Restore interrupted state - Thread.currentThread().interrupt(); - } - } - } - super.postProcess(); - } } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api.dart index 22eabf5d3be..ca6b5b3ef63 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api.dart @@ -47,28 +47,19 @@ class Openapi { void setOAuthToken(String name, String token) { if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) - as OAuthInterceptor) - .tokens[name] = token; + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token; } } void setBasicAuth(String name, String username, String password) { if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) - as BasicAuthInterceptor) - .authInfo[name] = BasicAuthInfo(username, password); + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); } } void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { - (this - .dio - .interceptors - .firstWhere((element) => element is ApiKeyAuthInterceptor) - as ApiKeyAuthInterceptor) - .apiKeys[name] = apiKey; + (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; } } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/another_fake_api.dart index 61e534aee7f..00d88a5c178 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/another_fake_api.dart @@ -10,6 +10,7 @@ import 'package:dio/dio.dart'; import 'package:openapi/src/model/model_client.dart'; class AnotherFakeApi { + final Dio _dio; final Serializers _serializers; @@ -19,7 +20,7 @@ class AnotherFakeApi { /// To test special tags /// /// To test special tags and operation ID starting with number - Future> call123testSpecialTags({ + Future> call123testSpecialTags({ required ModelClient modelClient, CancelToken? cancelToken, Map? headers, @@ -44,16 +45,18 @@ class AnotherFakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(ModelClient); _bodyData = _serializers.serialize(modelClient, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -81,6 +84,7 @@ class AnotherFakeApi { _response.data!, specifiedType: _responseType, ) as ModelClient; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -101,4 +105,5 @@ class AnotherFakeApi { extra: _response.extra, ); } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/default_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/default_api.dart index b4d3e174e31..48fc9b8c444 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/default_api.dart @@ -10,16 +10,17 @@ import 'package:dio/dio.dart'; import 'package:openapi/src/model/inline_response_default.dart'; class DefaultApi { + final Dio _dio; final Serializers _serializers; const DefaultApi(this._dio, this._serializers); + /// /// - /// - /// - Future> fooGet({ + /// + Future> fooGet({ CancelToken? cancelToken, Map? headers, Map? extra, @@ -43,7 +44,8 @@ class DefaultApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -62,6 +64,7 @@ class DefaultApi { _response.data!, specifiedType: _responseType, ) as InlineResponseDefault; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -82,4 +85,5 @@ class DefaultApi { extra: _response.extra, ); } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart index 0f1702646e2..8718f97fb60 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_api.dart @@ -19,6 +19,7 @@ import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; class FakeApi { + final Dio _dio; final Serializers _serializers; @@ -27,8 +28,8 @@ class FakeApi { /// Health check endpoint /// - /// - Future> fakeHealthGet({ + /// + Future> fakeHealthGet({ CancelToken? cancelToken, Map? headers, Map? extra, @@ -52,7 +53,8 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -71,6 +73,7 @@ class FakeApi { _response.data!, specifiedType: _responseType, ) as HealthCheckResult; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -94,8 +97,8 @@ class FakeApi { /// test http signature authentication /// - /// - Future> fakeHttpSignatureTest({ + /// + Future> fakeHttpSignatureTest({ required Pet pet, String? query1, String? header1, @@ -138,9 +141,10 @@ class FakeApi { try { const _type = FullType(Pet); _bodyData = _serializers.serialize(pet, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -163,10 +167,10 @@ class FakeApi { return _response; } - /// + /// /// /// Test serialization of outer boolean types - Future> fakeOuterBooleanSerialize({ + Future> fakeOuterBooleanSerialize({ bool? body, CancelToken? cancelToken, Map? headers, @@ -191,15 +195,17 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = body; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -223,6 +229,7 @@ class FakeApi { try { _responseData = _response.data as bool; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -244,10 +251,10 @@ class FakeApi { ); } - /// + /// /// /// Test serialization of object with outer number type - Future> fakeOuterCompositeSerialize({ + Future> fakeOuterCompositeSerialize({ OuterComposite? outerComposite, CancelToken? cancelToken, Map? headers, @@ -272,18 +279,18 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(OuterComposite); - _bodyData = outerComposite == null - ? null - : _serializers.serialize(outerComposite, specifiedType: _type); - } catch (error) { + _bodyData = outerComposite == null ? null : _serializers.serialize(outerComposite, specifiedType: _type); + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -311,6 +318,7 @@ class FakeApi { _response.data!, specifiedType: _responseType, ) as OuterComposite; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -332,10 +340,10 @@ class FakeApi { ); } - /// + /// /// /// Test serialization of outer number types - Future> fakeOuterNumberSerialize({ + Future> fakeOuterNumberSerialize({ num? body, CancelToken? cancelToken, Map? headers, @@ -360,15 +368,17 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = body; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -392,6 +402,7 @@ class FakeApi { try { _responseData = _response.data as num; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -413,10 +424,10 @@ class FakeApi { ); } - /// + /// /// /// Test serialization of outer string types - Future> fakeOuterStringSerialize({ + Future> fakeOuterStringSerialize({ String? body, CancelToken? cancelToken, Map? headers, @@ -441,15 +452,17 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = body; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -473,6 +486,7 @@ class FakeApi { try { _responseData = _response.data as String; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -494,11 +508,10 @@ class FakeApi { ); } - /// + /// /// /// Test serialization of enum (int) properties with examples - Future> - fakePropertyEnumIntegerSerialize({ + Future> fakePropertyEnumIntegerSerialize({ required OuterObjectWithEnumProperty outerObjectWithEnumProperty, CancelToken? cancelToken, Map? headers, @@ -523,17 +536,18 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(OuterObjectWithEnumProperty); - _bodyData = _serializers.serialize(outerObjectWithEnumProperty, - specifiedType: _type); - } catch (error) { + _bodyData = _serializers.serialize(outerObjectWithEnumProperty, specifiedType: _type); + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -561,6 +575,7 @@ class FakeApi { _response.data!, specifiedType: _responseType, ) as OuterObjectWithEnumProperty; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -582,10 +597,10 @@ class FakeApi { ); } - /// + /// /// /// For this test, the body for this request much reference a schema named `File`. - Future> testBodyWithFileSchema({ + Future> testBodyWithFileSchema({ required FileSchemaTestClass fileSchemaTestClass, CancelToken? cancelToken, Map? headers, @@ -610,17 +625,18 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(FileSchemaTestClass); - _bodyData = - _serializers.serialize(fileSchemaTestClass, specifiedType: _type); - } catch (error) { + _bodyData = _serializers.serialize(fileSchemaTestClass, specifiedType: _type); + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -643,10 +659,10 @@ class FakeApi { return _response; } + /// /// - /// - /// - Future> testBodyWithQueryParams({ + /// + Future> testBodyWithQueryParams({ required String query, required User user, CancelToken? cancelToken, @@ -681,9 +697,10 @@ class FakeApi { try { const _type = FullType(User); _bodyData = _serializers.serialize(user, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -709,7 +726,7 @@ class FakeApi { /// To test \"client\" model /// /// To test \"client\" model - Future> testClientModel({ + Future> testClientModel({ required ModelClient modelClient, CancelToken? cancelToken, Map? headers, @@ -734,16 +751,18 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(ModelClient); _bodyData = _serializers.serialize(modelClient, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -771,6 +790,7 @@ class FakeApi { _response.data!, specifiedType: _responseType, ) as ModelClient; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -792,10 +812,10 @@ class FakeApi { ); } - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 /// - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - Future> testEndpointParameters({ + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + Future> testEndpointParameters({ required num number, required double double_, required String patternWithoutDelimiter, @@ -838,53 +858,32 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = { - if (integer != null) - r'integer': - encodeFormParameter(_serializers, integer, const FullType(int)), - if (int32 != null) - r'int32': - encodeFormParameter(_serializers, int32, const FullType(int)), - if (int64 != null) - r'int64': - encodeFormParameter(_serializers, int64, const FullType(int)), - r'number': - encodeFormParameter(_serializers, number, const FullType(num)), - if (float != null) - r'float': - encodeFormParameter(_serializers, float, const FullType(double)), - r'double': - encodeFormParameter(_serializers, double_, const FullType(double)), - if (string != null) - r'string': - encodeFormParameter(_serializers, string, const FullType(String)), - r'pattern_without_delimiter': encodeFormParameter( - _serializers, patternWithoutDelimiter, const FullType(String)), - r'byte': - encodeFormParameter(_serializers, byte, const FullType(String)), - if (binary != null) - r'binary': MultipartFile.fromBytes(binary, filename: r'binary'), - if (date != null) - r'date': - encodeFormParameter(_serializers, date, const FullType(DateTime)), - if (dateTime != null) - r'dateTime': encodeFormParameter( - _serializers, dateTime, const FullType(DateTime)), - if (password != null) - r'password': encodeFormParameter( - _serializers, password, const FullType(String)), - if (callback != null) - r'callback': encodeFormParameter( - _serializers, callback, const FullType(String)), + if (integer != null) r'integer': encodeFormParameter(_serializers, integer, const FullType(int)), + if (int32 != null) r'int32': encodeFormParameter(_serializers, int32, const FullType(int)), + if (int64 != null) r'int64': encodeFormParameter(_serializers, int64, const FullType(int)), + r'number': encodeFormParameter(_serializers, number, const FullType(num)), + if (float != null) r'float': encodeFormParameter(_serializers, float, const FullType(double)), + r'double': encodeFormParameter(_serializers, double_, const FullType(double)), + if (string != null) r'string': encodeFormParameter(_serializers, string, const FullType(String)), + r'pattern_without_delimiter': encodeFormParameter(_serializers, patternWithoutDelimiter, const FullType(String)), + r'byte': encodeFormParameter(_serializers, byte, const FullType(String)), + if (binary != null) r'binary': MultipartFile.fromBytes(binary, filename: r'binary'), + if (date != null) r'date': encodeFormParameter(_serializers, date, const FullType(DateTime)), + if (dateTime != null) r'dateTime': encodeFormParameter(_serializers, dateTime, const FullType(DateTime)), + if (password != null) r'password': encodeFormParameter(_serializers, password, const FullType(String)), + if (callback != null) r'callback': encodeFormParameter(_serializers, callback, const FullType(String)), }; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -910,7 +909,7 @@ class FakeApi { /// To test enum parameters /// /// To test enum parameters - Future> testEnumParameters({ + Future> testEnumParameters({ BuiltList? enumHeaderStringArray, String? enumHeaderString, BuiltList? enumQueryStringArray, @@ -930,8 +929,7 @@ class FakeApi { final _options = Options( method: r'GET', headers: { - if (enumHeaderStringArray != null) - r'enum_header_string_array': enumHeaderStringArray, + if (enumHeaderStringArray != null) r'enum_header_string_array': enumHeaderStringArray, if (enumHeaderString != null) r'enum_header_string': enumHeaderString, ...?headers, }, @@ -946,8 +944,7 @@ class FakeApi { ); final _queryParameters = { - if (enumQueryStringArray != null) - r'enum_query_string_array': enumQueryStringArray, + if (enumQueryStringArray != null) r'enum_query_string_array': enumQueryStringArray, if (enumQueryString != null) r'enum_query_string': enumQueryString, if (enumQueryInteger != null) r'enum_query_integer': enumQueryInteger, if (enumQueryDouble != null) r'enum_query_double': enumQueryDouble, @@ -957,18 +954,13 @@ class FakeApi { try { _bodyData = { - if (enumFormStringArray != null) - r'enum_form_string_array': encodeFormParameter( - _serializers, - enumFormStringArray, - const FullType(BuiltList, [FullType(String)])), - if (enumFormString != null) - r'enum_form_string': encodeFormParameter( - _serializers, enumFormString, const FullType(String)), + if (enumFormStringArray != null) r'enum_form_string_array': encodeFormParameter(_serializers, enumFormStringArray, const FullType(BuiltList, [FullType(String)])), + if (enumFormString != null) r'enum_form_string': encodeFormParameter(_serializers, enumFormString, const FullType(String)), }; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -994,7 +986,7 @@ class FakeApi { /// Fake endpoint to test group parameters (optional) /// /// Fake endpoint to test group parameters (optional) - Future> testGroupParameters({ + Future> testGroupParameters({ required int requiredStringGroup, required bool requiredBooleanGroup, required int requiredInt64Group, @@ -1052,8 +1044,8 @@ class FakeApi { /// test inline additionalProperties /// - /// - Future> testInlineAdditionalProperties({ + /// + Future> testInlineAdditionalProperties({ required BuiltMap requestBody, CancelToken? cancelToken, Map? headers, @@ -1078,16 +1070,18 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(BuiltMap, [FullType(String), FullType(String)]); _bodyData = _serializers.serialize(requestBody, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -1112,8 +1106,8 @@ class FakeApi { /// test json serialization of form data /// - /// - Future> testJsonFormData({ + /// + Future> testJsonFormData({ required String param, required String param2, CancelToken? cancelToken, @@ -1139,20 +1133,20 @@ class FakeApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = { - r'param': - encodeFormParameter(_serializers, param, const FullType(String)), - r'param2': - encodeFormParameter(_serializers, param2, const FullType(String)), + r'param': encodeFormParameter(_serializers, param, const FullType(String)), + r'param2': encodeFormParameter(_serializers, param2, const FullType(String)), }; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -1175,10 +1169,10 @@ class FakeApi { return _response; } - /// + /// /// /// To test the collection format in query parameters - Future> testQueryParameterCollectionFormat({ + Future> testQueryParameterCollectionFormat({ required BuiltList pipe, required BuiltList ioutil, required BuiltList http, @@ -1226,4 +1220,5 @@ class FakeApi { return _response; } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_classname_tags123_api.dart index ee5248f3a5f..01d0383fd16 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/fake_classname_tags123_api.dart @@ -10,6 +10,7 @@ import 'package:dio/dio.dart'; import 'package:openapi/src/model/model_client.dart'; class FakeClassnameTags123Api { + final Dio _dio; final Serializers _serializers; @@ -19,7 +20,7 @@ class FakeClassnameTags123Api { /// To test class name in snake case /// /// To test class name in snake case - Future> testClassname({ + Future> testClassname({ required ModelClient modelClient, CancelToken? cancelToken, Map? headers, @@ -51,16 +52,18 @@ class FakeClassnameTags123Api { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(ModelClient); _bodyData = _serializers.serialize(modelClient, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -88,6 +91,7 @@ class FakeClassnameTags123Api { _response.data!, specifiedType: _responseType, ) as ModelClient; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -108,4 +112,5 @@ class FakeClassnameTags123Api { extra: _response.extra, ); } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/pet_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/pet_api.dart index be85fa07b04..da4b3a61a67 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/pet_api.dart @@ -14,6 +14,7 @@ import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; class PetApi { + final Dio _dio; final Serializers _serializers; @@ -22,8 +23,8 @@ class PetApi { /// Add a new pet to the store /// - /// - Future> addPet({ + /// + Future> addPet({ required Pet pet, CancelToken? cancelToken, Map? headers, @@ -54,16 +55,18 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(Pet); _bodyData = _serializers.serialize(pet, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -88,8 +91,8 @@ class PetApi { /// Deletes a pet /// - /// - Future> deletePet({ + /// + Future> deletePet({ required int petId, String? apiKey, CancelToken? cancelToken, @@ -99,8 +102,7 @@ class PetApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = - r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); + final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); final _options = Options( method: r'DELETE', headers: { @@ -122,7 +124,8 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -139,7 +142,7 @@ class PetApi { /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings - Future>> findPetsByStatus({ + Future>> findPetsByStatus({ required BuiltList status, CancelToken? cancelToken, Map? headers, @@ -190,6 +193,7 @@ class PetApi { _response.data!, specifiedType: _responseType, ) as BuiltList; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -214,7 +218,7 @@ class PetApi { /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - Future>> findPetsByTags({ + Future>> findPetsByTags({ required BuiltSet tags, CancelToken? cancelToken, Map? headers, @@ -265,6 +269,7 @@ class PetApi { _response.data!, specifiedType: _responseType, ) as BuiltSet; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -289,7 +294,7 @@ class PetApi { /// Find pet by ID /// /// Returns a single pet - Future> getPetById({ + Future> getPetById({ required int petId, CancelToken? cancelToken, Map? headers, @@ -298,8 +303,7 @@ class PetApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = - r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); + final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); final _options = Options( method: r'GET', headers: { @@ -322,7 +326,8 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -341,6 +346,7 @@ class PetApi { _response.data!, specifiedType: _responseType, ) as Pet; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -364,8 +370,8 @@ class PetApi { /// Update an existing pet /// - /// - Future> updatePet({ + /// + Future> updatePet({ required Pet pet, CancelToken? cancelToken, Map? headers, @@ -396,16 +402,18 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(Pet); _bodyData = _serializers.serialize(pet, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -430,8 +438,8 @@ class PetApi { /// Updates a pet in the store with form data /// - /// - Future> updatePetWithForm({ + /// + Future> updatePetWithForm({ required int petId, String? name, String? status, @@ -442,8 +450,7 @@ class PetApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = - r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); + final _path = r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()); final _options = Options( method: r'POST', headers: { @@ -464,22 +471,20 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = { - if (name != null) - r'name': - encodeFormParameter(_serializers, name, const FullType(String)), - if (status != null) - r'status': - encodeFormParameter(_serializers, status, const FullType(String)), + if (name != null) r'name': encodeFormParameter(_serializers, name, const FullType(String)), + if (status != null) r'status': encodeFormParameter(_serializers, status, const FullType(String)), }; - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -504,8 +509,8 @@ class PetApi { /// uploads an image /// - /// - Future> uploadFile({ + /// + Future> uploadFile({ required int petId, String? additionalMetadata, Uint8List? file, @@ -516,8 +521,7 @@ class PetApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/pet/{petId}/uploadImage' - .replaceAll('{' r'petId' '}', petId.toString()); + final _path = r'/pet/{petId}/uploadImage'.replaceAll('{' r'petId' '}', petId.toString()); final _options = Options( method: r'POST', headers: { @@ -538,21 +542,20 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = FormData.fromMap({ - if (additionalMetadata != null) - r'additionalMetadata': encodeFormParameter( - _serializers, additionalMetadata, const FullType(String)), - if (file != null) - r'file': MultipartFile.fromBytes(file, filename: r'file'), + if (additionalMetadata != null) r'additionalMetadata': encodeFormParameter(_serializers, additionalMetadata, const FullType(String)), + if (file != null) r'file': MultipartFile.fromBytes(file, filename: r'file'), }); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -580,6 +583,7 @@ class PetApi { _response.data!, specifiedType: _responseType, ) as ApiResponse; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -603,8 +607,8 @@ class PetApi { /// uploads an image (required) /// - /// - Future> uploadFileWithRequiredFile({ + /// + Future> uploadFileWithRequiredFile({ required int petId, required Uint8List requiredFile, String? additionalMetadata, @@ -615,8 +619,7 @@ class PetApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/fake/{petId}/uploadImageWithRequiredFile' - .replaceAll('{' r'petId' '}', petId.toString()); + final _path = r'/fake/{petId}/uploadImageWithRequiredFile'.replaceAll('{' r'petId' '}', petId.toString()); final _options = Options( method: r'POST', headers: { @@ -637,21 +640,20 @@ class PetApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { _bodyData = FormData.fromMap({ - if (additionalMetadata != null) - r'additionalMetadata': encodeFormParameter( - _serializers, additionalMetadata, const FullType(String)), - r'requiredFile': - MultipartFile.fromBytes(requiredFile, filename: r'requiredFile'), + if (additionalMetadata != null) r'additionalMetadata': encodeFormParameter(_serializers, additionalMetadata, const FullType(String)), + r'requiredFile': MultipartFile.fromBytes(requiredFile, filename: r'requiredFile'), }); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -679,6 +681,7 @@ class PetApi { _response.data!, specifiedType: _responseType, ) as ApiResponse; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -699,4 +702,5 @@ class PetApi { extra: _response.extra, ); } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/store_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/store_api.dart index b4e470b1133..36bf3a5d680 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/store_api.dart @@ -11,6 +11,7 @@ import 'package:openapi/src/model/order.dart'; import 'package:built_collection/built_collection.dart'; class StoreApi { + final Dio _dio; final Serializers _serializers; @@ -20,7 +21,7 @@ class StoreApi { /// Delete purchase order by ID /// /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - Future> deleteOrder({ + Future> deleteOrder({ required String orderId, CancelToken? cancelToken, Map? headers, @@ -29,8 +30,7 @@ class StoreApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/store/order/{order_id}' - .replaceAll('{' r'order_id' '}', orderId.toString()); + final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', orderId.toString()); final _options = Options( method: r'DELETE', headers: { @@ -46,7 +46,8 @@ class StoreApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -63,7 +64,7 @@ class StoreApi { /// Returns pet inventories by status /// /// Returns a map of status codes to quantities - Future>> getInventory({ + Future>> getInventory({ CancelToken? cancelToken, Map? headers, Map? extra, @@ -94,7 +95,8 @@ class StoreApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -108,12 +110,12 @@ class StoreApi { BuiltMap _responseData; try { - const _responseType = - FullType(BuiltMap, [FullType(String), FullType(int)]); + const _responseType = FullType(BuiltMap, [FullType(String), FullType(int)]); _responseData = _serializers.deserialize( _response.data!, specifiedType: _responseType, ) as BuiltMap; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -138,7 +140,7 @@ class StoreApi { /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - Future> getOrderById({ + Future> getOrderById({ required int orderId, CancelToken? cancelToken, Map? headers, @@ -147,8 +149,7 @@ class StoreApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/store/order/{order_id}' - .replaceAll('{' r'order_id' '}', orderId.toString()); + final _path = r'/store/order/{order_id}'.replaceAll('{' r'order_id' '}', orderId.toString()); final _options = Options( method: r'GET', headers: { @@ -164,7 +165,8 @@ class StoreApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -183,6 +185,7 @@ class StoreApi { _response.data!, specifiedType: _responseType, ) as Order; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -206,8 +209,8 @@ class StoreApi { /// Place an order for a pet /// - /// - Future> placeOrder({ + /// + Future> placeOrder({ required Order order, CancelToken? cancelToken, Map? headers, @@ -232,16 +235,18 @@ class StoreApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(Order); _bodyData = _serializers.serialize(order, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -269,6 +274,7 @@ class StoreApi { _response.data!, specifiedType: _responseType, ) as Order; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -289,4 +295,5 @@ class StoreApi { extra: _response.extra, ); } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/user_api.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/user_api.dart index 91d22855862..e07516cb32e 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api/user_api.dart @@ -11,6 +11,7 @@ import 'package:openapi/src/model/user.dart'; import 'package:built_collection/built_collection.dart'; class UserApi { + final Dio _dio; final Serializers _serializers; @@ -20,7 +21,7 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future> createUser({ + Future> createUser({ required User user, CancelToken? cancelToken, Map? headers, @@ -45,16 +46,18 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(User); _bodyData = _serializers.serialize(user, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -79,8 +82,8 @@ class UserApi { /// Creates list of users with given input array /// - /// - Future> createUsersWithArrayInput({ + /// + Future> createUsersWithArrayInput({ required BuiltList user, CancelToken? cancelToken, Map? headers, @@ -105,16 +108,18 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(BuiltList, [FullType(User)]); _bodyData = _serializers.serialize(user, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -139,8 +144,8 @@ class UserApi { /// Creates list of users with given input array /// - /// - Future> createUsersWithListInput({ + /// + Future> createUsersWithListInput({ required BuiltList user, CancelToken? cancelToken, Map? headers, @@ -165,16 +170,18 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(BuiltList, [FullType(User)]); _bodyData = _serializers.serialize(user, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -200,7 +207,7 @@ class UserApi { /// Delete user /// /// This can only be done by the logged in user. - Future> deleteUser({ + Future> deleteUser({ required String username, CancelToken? cancelToken, Map? headers, @@ -209,8 +216,7 @@ class UserApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/user/{username}' - .replaceAll('{' r'username' '}', username.toString()); + final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()); final _options = Options( method: r'DELETE', headers: { @@ -226,7 +232,8 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -242,8 +249,8 @@ class UserApi { /// Get user by user name /// - /// - Future> getUserByName({ + /// + Future> getUserByName({ required String username, CancelToken? cancelToken, Map? headers, @@ -252,8 +259,7 @@ class UserApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/user/{username}' - .replaceAll('{' r'username' '}', username.toString()); + final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()); final _options = Options( method: r'GET', headers: { @@ -269,7 +275,8 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -288,6 +295,7 @@ class UserApi { _response.data!, specifiedType: _responseType, ) as User; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -311,8 +319,8 @@ class UserApi { /// Logs user into the system /// - /// - Future> loginUser({ + /// + Future> loginUser({ required String username, required String password, CancelToken? cancelToken, @@ -356,6 +364,7 @@ class UserApi { try { _responseData = _response.data as String; + } catch (error) { throw DioError( requestOptions: _response.requestOptions, @@ -379,8 +388,8 @@ class UserApi { /// Logs out current logged in user session /// - /// - Future> logoutUser({ + /// + Future> logoutUser({ CancelToken? cancelToken, Map? headers, Map? extra, @@ -404,7 +413,8 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; final _response = await _dio.request( _path, @@ -421,7 +431,7 @@ class UserApi { /// Updated user /// /// This can only be done by the logged in user. - Future> updateUser({ + Future> updateUser({ required String username, required User user, CancelToken? cancelToken, @@ -431,8 +441,7 @@ class UserApi { ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/user/{username}' - .replaceAll('{' r'username' '}', username.toString()); + final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()); final _options = Options( method: r'PUT', headers: { @@ -448,16 +457,18 @@ class UserApi { validateStatus: validateStatus, ); - final _queryParameters = {}; + final _queryParameters = { + }; dynamic _bodyData; try { const _type = FullType(User); _bodyData = _serializers.serialize(user, specifiedType: _type); - } catch (error) { + + } catch(error) { throw DioError( - requestOptions: _options.compose( + requestOptions: _options.compose( _dio.options, _path, queryParameters: _queryParameters, @@ -479,4 +490,5 @@ class UserApi { return _response; } + } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api_util.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api_util.dart index 538ec770ae8..ca7832e3693 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api_util.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/api_util.dart @@ -10,8 +10,7 @@ import 'package:built_value/serializer.dart'; /// Format the given form parameter object into something that Dio can handle. /// Returns primitive or String. /// Returns List/Map if the value is BuildList/BuiltMap. -dynamic encodeFormParameter( - Serializers serializers, dynamic value, FullType type) { +dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) { if (value == null) { return ''; } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/api_key_auth.dart index da0f9f2fe18..a4257360547 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/api_key_auth.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/api_key_auth.dart @@ -2,6 +2,7 @@ // AUTO-GENERATED FILE, DO NOT MODIFY! // + import 'package:dio/dio.dart'; import 'package:openapi/src/auth/auth.dart'; diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/basic_auth.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/basic_auth.dart index fb3a768a8ac..d34b65d3e7b 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/basic_auth.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/auth/basic_auth.dart @@ -27,8 +27,7 @@ class BasicAuthInterceptor extends AuthInterceptor { final authName = info['name'] as String; final basicAuthInfo = authInfo[authName]; if (basicAuthInfo != null) { - final basicAuth = - 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}'; + final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}'; options.headers['Authorization'] = basicAuth; break; } diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart index 3010d03524d..f92d8336bbb 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart @@ -8,90 +8,73 @@ import 'package:built_value/serializer.dart'; part 'additional_properties_class.g.dart'; -abstract class AdditionalPropertiesClass - implements - Built { - @BuiltValueField(wireName: r'map_property') - BuiltMap? get mapProperty; - @BuiltValueField(wireName: r'map_of_map_property') - BuiltMap>? get mapOfMapProperty; - AdditionalPropertiesClass._(); +abstract class AdditionalPropertiesClass implements Built { + @BuiltValueField(wireName: r'map_property') + BuiltMap? get mapProperty; - static void _initializeBuilder(AdditionalPropertiesClassBuilder b) => b; + @BuiltValueField(wireName: r'map_of_map_property') + BuiltMap>? get mapOfMapProperty; - factory AdditionalPropertiesClass( - [void updates(AdditionalPropertiesClassBuilder b)]) = - _$AdditionalPropertiesClass; + AdditionalPropertiesClass._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$AdditionalPropertiesClassSerializer(); + static void _initializeBuilder(AdditionalPropertiesClassBuilder b) => b; + + factory AdditionalPropertiesClass([void updates(AdditionalPropertiesClassBuilder b)]) = _$AdditionalPropertiesClass; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AdditionalPropertiesClassSerializer(); } -class _$AdditionalPropertiesClassSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - AdditionalPropertiesClass, - _$AdditionalPropertiesClass - ]; +class _$AdditionalPropertiesClassSerializer implements StructuredSerializer { + @override + final Iterable types = const [AdditionalPropertiesClass, _$AdditionalPropertiesClass]; - @override - final String wireName = r'AdditionalPropertiesClass'; + @override + final String wireName = r'AdditionalPropertiesClass'; - @override - Iterable serialize( - Serializers serializers, AdditionalPropertiesClass object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.mapProperty != null) { - result - ..add(r'map_property') - ..add(serializers.serialize(object.mapProperty, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(String)]))); + @override + Iterable serialize(Serializers serializers, AdditionalPropertiesClass object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.mapProperty != null) { + result + ..add(r'map_property') + ..add(serializers.serialize(object.mapProperty, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]))); + } + if (object.mapOfMapProperty != null) { + result + ..add(r'map_of_map_property') + ..add(serializers.serialize(object.mapOfMapProperty, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]))); + } + return result; } - if (object.mapOfMapProperty != null) { - result - ..add(r'map_of_map_property') - ..add(serializers.serialize(object.mapOfMapProperty, - specifiedType: const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltMap, [FullType(String), FullType(String)]) - ]))); - } - return result; - } - @override - AdditionalPropertiesClass deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = AdditionalPropertiesClassBuilder(); + @override + AdditionalPropertiesClass deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = AdditionalPropertiesClassBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'map_property': - result.mapProperty.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(String)])) - as BuiltMap); - break; - case r'map_of_map_property': - result.mapOfMapProperty.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltMap, [FullType(String), FullType(String)]) - ])) as BuiltMap>); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'map_property': + result.mapProperty.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)])) as BuiltMap); + break; + case r'map_of_map_property': + result.mapOfMapProperty.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])) as BuiltMap>); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/animal.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/animal.dart index 5100660356d..14419f9eca4 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/animal.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/animal.dart @@ -7,68 +7,72 @@ import 'package:built_value/serializer.dart'; part 'animal.g.dart'; + + abstract class Animal implements Built { - @BuiltValueField(wireName: r'className') - String get className; + @BuiltValueField(wireName: r'className') + String get className; - @BuiltValueField(wireName: r'color') - String? get color; + @BuiltValueField(wireName: r'color') + String? get color; - Animal._(); + Animal._(); - static void _initializeBuilder(AnimalBuilder b) => b..color = 'red'; + static void _initializeBuilder(AnimalBuilder b) => b + ..color = 'red'; - factory Animal([void updates(AnimalBuilder b)]) = _$Animal; + factory Animal([void updates(AnimalBuilder b)]) = _$Animal; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$AnimalSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AnimalSerializer(); } class _$AnimalSerializer implements StructuredSerializer { - @override - final Iterable types = const [Animal, _$Animal]; + @override + final Iterable types = const [Animal, _$Animal]; - @override - final String wireName = r'Animal'; + @override + final String wireName = r'Animal'; - @override - Iterable serialize(Serializers serializers, Animal object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - result - ..add(r'className') - ..add(serializers.serialize(object.className, - specifiedType: const FullType(String))); - if (object.color != null) { - result - ..add(r'color') - ..add(serializers.serialize(object.color, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, Animal object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + result + ..add(r'className') + ..add(serializers.serialize(object.className, + specifiedType: const FullType(String))); + if (object.color != null) { + result + ..add(r'color') + ..add(serializers.serialize(object.color, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - Animal deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = AnimalBuilder(); + @override + Animal deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = AnimalBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'className': - result.className = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'color': - result.color = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'className': + result.className = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'color': + result.color = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/api_response.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/api_response.dart index b5745122ab7..4c9fa0b7159 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/api_response.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/api_response.dart @@ -7,83 +7,86 @@ import 'package:built_value/serializer.dart'; part 'api_response.g.dart'; + + abstract class ApiResponse implements Built { - @BuiltValueField(wireName: r'code') - int? get code; + @BuiltValueField(wireName: r'code') + int? get code; - @BuiltValueField(wireName: r'type') - String? get type; + @BuiltValueField(wireName: r'type') + String? get type; - @BuiltValueField(wireName: r'message') - String? get message; + @BuiltValueField(wireName: r'message') + String? get message; - ApiResponse._(); + ApiResponse._(); - static void _initializeBuilder(ApiResponseBuilder b) => b; + static void _initializeBuilder(ApiResponseBuilder b) => b; - factory ApiResponse([void updates(ApiResponseBuilder b)]) = _$ApiResponse; + factory ApiResponse([void updates(ApiResponseBuilder b)]) = _$ApiResponse; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ApiResponseSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ApiResponseSerializer(); } class _$ApiResponseSerializer implements StructuredSerializer { - @override - final Iterable types = const [ApiResponse, _$ApiResponse]; + @override + final Iterable types = const [ApiResponse, _$ApiResponse]; - @override - final String wireName = r'ApiResponse'; + @override + final String wireName = r'ApiResponse'; - @override - Iterable serialize(Serializers serializers, ApiResponse object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.code != null) { - result - ..add(r'code') - ..add(serializers.serialize(object.code, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, ApiResponse object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.code != null) { + result + ..add(r'code') + ..add(serializers.serialize(object.code, + specifiedType: const FullType(int))); + } + if (object.type != null) { + result + ..add(r'type') + ..add(serializers.serialize(object.type, + specifiedType: const FullType(String))); + } + if (object.message != null) { + result + ..add(r'message') + ..add(serializers.serialize(object.message, + specifiedType: const FullType(String))); + } + return result; } - if (object.type != null) { - result - ..add(r'type') - ..add(serializers.serialize(object.type, - specifiedType: const FullType(String))); - } - if (object.message != null) { - result - ..add(r'message') - ..add(serializers.serialize(object.message, - specifiedType: const FullType(String))); - } - return result; - } - @override - ApiResponse deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ApiResponseBuilder(); + @override + ApiResponse deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ApiResponseBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'code': - result.code = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'type': - result.type = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'message': - result.message = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'code': + result.code = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'type': + result.type = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'message': + result.message = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart index 7984e48b589..0f86aa08c5b 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_array_of_number_only.dart @@ -8,72 +8,60 @@ import 'package:built_value/serializer.dart'; part 'array_of_array_of_number_only.g.dart'; -abstract class ArrayOfArrayOfNumberOnly - implements - Built { - @BuiltValueField(wireName: r'ArrayArrayNumber') - BuiltList>? get arrayArrayNumber; - ArrayOfArrayOfNumberOnly._(); - static void _initializeBuilder(ArrayOfArrayOfNumberOnlyBuilder b) => b; +abstract class ArrayOfArrayOfNumberOnly implements Built { + @BuiltValueField(wireName: r'ArrayArrayNumber') + BuiltList>? get arrayArrayNumber; - factory ArrayOfArrayOfNumberOnly( - [void updates(ArrayOfArrayOfNumberOnlyBuilder b)]) = - _$ArrayOfArrayOfNumberOnly; + ArrayOfArrayOfNumberOnly._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$ArrayOfArrayOfNumberOnlySerializer(); + static void _initializeBuilder(ArrayOfArrayOfNumberOnlyBuilder b) => b; + + factory ArrayOfArrayOfNumberOnly([void updates(ArrayOfArrayOfNumberOnlyBuilder b)]) = _$ArrayOfArrayOfNumberOnly; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ArrayOfArrayOfNumberOnlySerializer(); } -class _$ArrayOfArrayOfNumberOnlySerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - ArrayOfArrayOfNumberOnly, - _$ArrayOfArrayOfNumberOnly - ]; +class _$ArrayOfArrayOfNumberOnlySerializer implements StructuredSerializer { + @override + final Iterable types = const [ArrayOfArrayOfNumberOnly, _$ArrayOfArrayOfNumberOnly]; - @override - final String wireName = r'ArrayOfArrayOfNumberOnly'; + @override + final String wireName = r'ArrayOfArrayOfNumberOnly'; - @override - Iterable serialize( - Serializers serializers, ArrayOfArrayOfNumberOnly object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.arrayArrayNumber != null) { - result - ..add(r'ArrayArrayNumber') - ..add(serializers.serialize(object.arrayArrayNumber, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(num)]) - ]))); + @override + Iterable serialize(Serializers serializers, ArrayOfArrayOfNumberOnly object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.arrayArrayNumber != null) { + result + ..add(r'ArrayArrayNumber') + ..add(serializers.serialize(object.arrayArrayNumber, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])]))); + } + return result; } - return result; - } - @override - ArrayOfArrayOfNumberOnly deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ArrayOfArrayOfNumberOnlyBuilder(); + @override + ArrayOfArrayOfNumberOnly deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ArrayOfArrayOfNumberOnlyBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'ArrayArrayNumber': - result.arrayArrayNumber.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(num)]) - ])) as BuiltList>); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'ArrayArrayNumber': + result.arrayArrayNumber.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(num)])])) as BuiltList>); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart index fc698bbc972..b68a04794aa 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_of_number_only.dart @@ -8,63 +8,60 @@ import 'package:built_value/serializer.dart'; part 'array_of_number_only.g.dart'; -abstract class ArrayOfNumberOnly - implements Built { - @BuiltValueField(wireName: r'ArrayNumber') - BuiltList? get arrayNumber; - ArrayOfNumberOnly._(); - static void _initializeBuilder(ArrayOfNumberOnlyBuilder b) => b; +abstract class ArrayOfNumberOnly implements Built { + @BuiltValueField(wireName: r'ArrayNumber') + BuiltList? get arrayNumber; - factory ArrayOfNumberOnly([void updates(ArrayOfNumberOnlyBuilder b)]) = - _$ArrayOfNumberOnly; + ArrayOfNumberOnly._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$ArrayOfNumberOnlySerializer(); + static void _initializeBuilder(ArrayOfNumberOnlyBuilder b) => b; + + factory ArrayOfNumberOnly([void updates(ArrayOfNumberOnlyBuilder b)]) = _$ArrayOfNumberOnly; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ArrayOfNumberOnlySerializer(); } -class _$ArrayOfNumberOnlySerializer - implements StructuredSerializer { - @override - final Iterable types = const [ArrayOfNumberOnly, _$ArrayOfNumberOnly]; +class _$ArrayOfNumberOnlySerializer implements StructuredSerializer { + @override + final Iterable types = const [ArrayOfNumberOnly, _$ArrayOfNumberOnly]; - @override - final String wireName = r'ArrayOfNumberOnly'; + @override + final String wireName = r'ArrayOfNumberOnly'; - @override - Iterable serialize(Serializers serializers, ArrayOfNumberOnly object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.arrayNumber != null) { - result - ..add(r'ArrayNumber') - ..add(serializers.serialize(object.arrayNumber, - specifiedType: const FullType(BuiltList, [FullType(num)]))); + @override + Iterable serialize(Serializers serializers, ArrayOfNumberOnly object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.arrayNumber != null) { + result + ..add(r'ArrayNumber') + ..add(serializers.serialize(object.arrayNumber, + specifiedType: const FullType(BuiltList, [FullType(num)]))); + } + return result; } - return result; - } - @override - ArrayOfNumberOnly deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ArrayOfNumberOnlyBuilder(); + @override + ArrayOfNumberOnly deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ArrayOfNumberOnlyBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'ArrayNumber': - result.arrayNumber.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(num)])) - as BuiltList); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'ArrayNumber': + result.arrayNumber.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(num)])) as BuiltList); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_test.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_test.dart index 113614e96a3..e9657764dc4 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_test.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/array_test.dart @@ -9,92 +9,86 @@ import 'package:built_value/serializer.dart'; part 'array_test.g.dart'; + + abstract class ArrayTest implements Built { - @BuiltValueField(wireName: r'array_of_string') - BuiltList? get arrayOfString; + @BuiltValueField(wireName: r'array_of_string') + BuiltList? get arrayOfString; - @BuiltValueField(wireName: r'array_array_of_integer') - BuiltList>? get arrayArrayOfInteger; + @BuiltValueField(wireName: r'array_array_of_integer') + BuiltList>? get arrayArrayOfInteger; - @BuiltValueField(wireName: r'array_array_of_model') - BuiltList>? get arrayArrayOfModel; + @BuiltValueField(wireName: r'array_array_of_model') + BuiltList>? get arrayArrayOfModel; - ArrayTest._(); + ArrayTest._(); - static void _initializeBuilder(ArrayTestBuilder b) => b; + static void _initializeBuilder(ArrayTestBuilder b) => b; - factory ArrayTest([void updates(ArrayTestBuilder b)]) = _$ArrayTest; + factory ArrayTest([void updates(ArrayTestBuilder b)]) = _$ArrayTest; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ArrayTestSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ArrayTestSerializer(); } class _$ArrayTestSerializer implements StructuredSerializer { - @override - final Iterable types = const [ArrayTest, _$ArrayTest]; + @override + final Iterable types = const [ArrayTest, _$ArrayTest]; - @override - final String wireName = r'ArrayTest'; + @override + final String wireName = r'ArrayTest'; - @override - Iterable serialize(Serializers serializers, ArrayTest object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.arrayOfString != null) { - result - ..add(r'array_of_string') - ..add(serializers.serialize(object.arrayOfString, - specifiedType: const FullType(BuiltList, [FullType(String)]))); + @override + Iterable serialize(Serializers serializers, ArrayTest object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.arrayOfString != null) { + result + ..add(r'array_of_string') + ..add(serializers.serialize(object.arrayOfString, + specifiedType: const FullType(BuiltList, [FullType(String)]))); + } + if (object.arrayArrayOfInteger != null) { + result + ..add(r'array_array_of_integer') + ..add(serializers.serialize(object.arrayArrayOfInteger, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])]))); + } + if (object.arrayArrayOfModel != null) { + result + ..add(r'array_array_of_model') + ..add(serializers.serialize(object.arrayArrayOfModel, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])]))); + } + return result; } - if (object.arrayArrayOfInteger != null) { - result - ..add(r'array_array_of_integer') - ..add(serializers.serialize(object.arrayArrayOfInteger, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(int)]) - ]))); - } - if (object.arrayArrayOfModel != null) { - result - ..add(r'array_array_of_model') - ..add(serializers.serialize(object.arrayArrayOfModel, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(ReadOnlyFirst)]) - ]))); - } - return result; - } - @override - ArrayTest deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ArrayTestBuilder(); + @override + ArrayTest deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ArrayTestBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'array_of_string': - result.arrayOfString.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(String)])) - as BuiltList); - break; - case r'array_array_of_integer': - result.arrayArrayOfInteger.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(int)]) - ])) as BuiltList>); - break; - case r'array_array_of_model': - result.arrayArrayOfModel.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [ - FullType(BuiltList, [FullType(ReadOnlyFirst)]) - ])) as BuiltList>); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'array_of_string': + result.arrayOfString.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(String)])) as BuiltList); + break; + case r'array_array_of_integer': + result.arrayArrayOfInteger.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(int)])])) as BuiltList>); + break; + case r'array_array_of_model': + result.arrayArrayOfModel.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(BuiltList, [FullType(ReadOnlyFirst)])])) as BuiltList>); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/capitalization.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/capitalization.dart index 3979912749c..9b7cd294db3 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/capitalization.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/capitalization.dart @@ -7,128 +7,126 @@ import 'package:built_value/serializer.dart'; part 'capitalization.g.dart'; -abstract class Capitalization - implements Built { - @BuiltValueField(wireName: r'smallCamel') - String? get smallCamel; - @BuiltValueField(wireName: r'CapitalCamel') - String? get capitalCamel; - @BuiltValueField(wireName: r'small_Snake') - String? get smallSnake; +abstract class Capitalization implements Built { + @BuiltValueField(wireName: r'smallCamel') + String? get smallCamel; - @BuiltValueField(wireName: r'Capital_Snake') - String? get capitalSnake; + @BuiltValueField(wireName: r'CapitalCamel') + String? get capitalCamel; - @BuiltValueField(wireName: r'SCA_ETH_Flow_Points') - String? get sCAETHFlowPoints; + @BuiltValueField(wireName: r'small_Snake') + String? get smallSnake; - /// Name of the pet - @BuiltValueField(wireName: r'ATT_NAME') - String? get ATT_NAME; + @BuiltValueField(wireName: r'Capital_Snake') + String? get capitalSnake; - Capitalization._(); + @BuiltValueField(wireName: r'SCA_ETH_Flow_Points') + String? get sCAETHFlowPoints; - static void _initializeBuilder(CapitalizationBuilder b) => b; + /// Name of the pet + @BuiltValueField(wireName: r'ATT_NAME') + String? get ATT_NAME; - factory Capitalization([void updates(CapitalizationBuilder b)]) = - _$Capitalization; + Capitalization._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$CapitalizationSerializer(); + static void _initializeBuilder(CapitalizationBuilder b) => b; + + factory Capitalization([void updates(CapitalizationBuilder b)]) = _$Capitalization; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CapitalizationSerializer(); } -class _$CapitalizationSerializer - implements StructuredSerializer { - @override - final Iterable types = const [Capitalization, _$Capitalization]; +class _$CapitalizationSerializer implements StructuredSerializer { + @override + final Iterable types = const [Capitalization, _$Capitalization]; - @override - final String wireName = r'Capitalization'; + @override + final String wireName = r'Capitalization'; - @override - Iterable serialize(Serializers serializers, Capitalization object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.smallCamel != null) { - result - ..add(r'smallCamel') - ..add(serializers.serialize(object.smallCamel, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, Capitalization object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.smallCamel != null) { + result + ..add(r'smallCamel') + ..add(serializers.serialize(object.smallCamel, + specifiedType: const FullType(String))); + } + if (object.capitalCamel != null) { + result + ..add(r'CapitalCamel') + ..add(serializers.serialize(object.capitalCamel, + specifiedType: const FullType(String))); + } + if (object.smallSnake != null) { + result + ..add(r'small_Snake') + ..add(serializers.serialize(object.smallSnake, + specifiedType: const FullType(String))); + } + if (object.capitalSnake != null) { + result + ..add(r'Capital_Snake') + ..add(serializers.serialize(object.capitalSnake, + specifiedType: const FullType(String))); + } + if (object.sCAETHFlowPoints != null) { + result + ..add(r'SCA_ETH_Flow_Points') + ..add(serializers.serialize(object.sCAETHFlowPoints, + specifiedType: const FullType(String))); + } + if (object.ATT_NAME != null) { + result + ..add(r'ATT_NAME') + ..add(serializers.serialize(object.ATT_NAME, + specifiedType: const FullType(String))); + } + return result; } - if (object.capitalCamel != null) { - result - ..add(r'CapitalCamel') - ..add(serializers.serialize(object.capitalCamel, - specifiedType: const FullType(String))); - } - if (object.smallSnake != null) { - result - ..add(r'small_Snake') - ..add(serializers.serialize(object.smallSnake, - specifiedType: const FullType(String))); - } - if (object.capitalSnake != null) { - result - ..add(r'Capital_Snake') - ..add(serializers.serialize(object.capitalSnake, - specifiedType: const FullType(String))); - } - if (object.sCAETHFlowPoints != null) { - result - ..add(r'SCA_ETH_Flow_Points') - ..add(serializers.serialize(object.sCAETHFlowPoints, - specifiedType: const FullType(String))); - } - if (object.ATT_NAME != null) { - result - ..add(r'ATT_NAME') - ..add(serializers.serialize(object.ATT_NAME, - specifiedType: const FullType(String))); - } - return result; - } - @override - Capitalization deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = CapitalizationBuilder(); + @override + Capitalization deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CapitalizationBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'smallCamel': - result.smallCamel = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'CapitalCamel': - result.capitalCamel = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'small_Snake': - result.smallSnake = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'Capital_Snake': - result.capitalSnake = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'SCA_ETH_Flow_Points': - result.sCAETHFlowPoints = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'ATT_NAME': - result.ATT_NAME = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'smallCamel': + result.smallCamel = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'CapitalCamel': + result.capitalCamel = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'small_Snake': + result.smallSnake = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'Capital_Snake': + result.capitalSnake = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'SCA_ETH_Flow_Points': + result.sCAETHFlowPoints = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'ATT_NAME': + result.ATT_NAME = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat.dart index dc3de81da9a..1ee68912ba7 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat.dart @@ -12,80 +12,82 @@ part 'cat.g.dart'; // ignore_for_file: unused_import abstract class Cat implements Built { - @BuiltValueField(wireName: r'className') - String get className; + @BuiltValueField(wireName: r'className') + String get className; - @BuiltValueField(wireName: r'color') - String? get color; + @BuiltValueField(wireName: r'color') + String? get color; - @BuiltValueField(wireName: r'declawed') - bool? get declawed; + @BuiltValueField(wireName: r'declawed') + bool? get declawed; - Cat._(); + Cat._(); - static void _initializeBuilder(CatBuilder b) => b..color = 'red'; + static void _initializeBuilder(CatBuilder b) => b + ..color = 'red'; - factory Cat([void updates(CatBuilder b)]) = _$Cat; + factory Cat([void updates(CatBuilder b)]) = _$Cat; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CatSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CatSerializer(); } class _$CatSerializer implements StructuredSerializer { - @override - final Iterable types = const [Cat, _$Cat]; + @override + final Iterable types = const [Cat, _$Cat]; - @override - final String wireName = r'Cat'; + @override + final String wireName = r'Cat'; - @override - Iterable serialize(Serializers serializers, Cat object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - result - ..add(r'className') - ..add(serializers.serialize(object.className, - specifiedType: const FullType(String))); - if (object.color != null) { - result - ..add(r'color') - ..add(serializers.serialize(object.color, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, Cat object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + result + ..add(r'className') + ..add(serializers.serialize(object.className, + specifiedType: const FullType(String))); + if (object.color != null) { + result + ..add(r'color') + ..add(serializers.serialize(object.color, + specifiedType: const FullType(String))); + } + if (object.declawed != null) { + result + ..add(r'declawed') + ..add(serializers.serialize(object.declawed, + specifiedType: const FullType(bool))); + } + return result; } - if (object.declawed != null) { - result - ..add(r'declawed') - ..add(serializers.serialize(object.declawed, - specifiedType: const FullType(bool))); - } - return result; - } - @override - Cat deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = CatBuilder(); + @override + Cat deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CatBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'className': - result.className = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'color': - result.color = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'declawed': - result.declawed = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'className': + result.className = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'color': + result.color = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'declawed': + result.declawed = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat_all_of.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat_all_of.dart index fcecefcccee..cbbf6321603 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat_all_of.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/cat_all_of.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'cat_all_of.g.dart'; + + abstract class CatAllOf implements Built { - @BuiltValueField(wireName: r'declawed') - bool? get declawed; + @BuiltValueField(wireName: r'declawed') + bool? get declawed; - CatAllOf._(); + CatAllOf._(); - static void _initializeBuilder(CatAllOfBuilder b) => b; + static void _initializeBuilder(CatAllOfBuilder b) => b; - factory CatAllOf([void updates(CatAllOfBuilder b)]) = _$CatAllOf; + factory CatAllOf([void updates(CatAllOfBuilder b)]) = _$CatAllOf; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CatAllOfSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CatAllOfSerializer(); } class _$CatAllOfSerializer implements StructuredSerializer { - @override - final Iterable types = const [CatAllOf, _$CatAllOf]; + @override + final Iterable types = const [CatAllOf, _$CatAllOf]; - @override - final String wireName = r'CatAllOf'; + @override + final String wireName = r'CatAllOf'; - @override - Iterable serialize(Serializers serializers, CatAllOf object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.declawed != null) { - result - ..add(r'declawed') - ..add(serializers.serialize(object.declawed, - specifiedType: const FullType(bool))); + @override + Iterable serialize(Serializers serializers, CatAllOf object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.declawed != null) { + result + ..add(r'declawed') + ..add(serializers.serialize(object.declawed, + specifiedType: const FullType(bool))); + } + return result; } - return result; - } - @override - CatAllOf deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = CatAllOfBuilder(); + @override + CatAllOf deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CatAllOfBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'declawed': - result.declawed = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'declawed': + result.declawed = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/category.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/category.dart index bca77eb1edb..3bc36cefbcc 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/category.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/category.dart @@ -7,68 +7,72 @@ import 'package:built_value/serializer.dart'; part 'category.g.dart'; + + abstract class Category implements Built { - @BuiltValueField(wireName: r'id') - int? get id; + @BuiltValueField(wireName: r'id') + int? get id; - @BuiltValueField(wireName: r'name') - String get name; + @BuiltValueField(wireName: r'name') + String get name; - Category._(); + Category._(); - static void _initializeBuilder(CategoryBuilder b) => b..name = 'default-name'; + static void _initializeBuilder(CategoryBuilder b) => b + ..name = 'default-name'; - factory Category([void updates(CategoryBuilder b)]) = _$Category; + factory Category([void updates(CategoryBuilder b)]) = _$Category; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CategorySerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CategorySerializer(); } class _$CategorySerializer implements StructuredSerializer { - @override - final Iterable types = const [Category, _$Category]; + @override + final Iterable types = const [Category, _$Category]; - @override - final String wireName = r'Category'; + @override + final String wireName = r'Category'; - @override - Iterable serialize(Serializers serializers, Category object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.id != null) { - result - ..add(r'id') - ..add(serializers.serialize(object.id, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Category object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.id != null) { + result + ..add(r'id') + ..add(serializers.serialize(object.id, + specifiedType: const FullType(int))); + } + result + ..add(r'name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(String))); + return result; } - result - ..add(r'name') - ..add(serializers.serialize(object.name, - specifiedType: const FullType(String))); - return result; - } - @override - Category deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = CategoryBuilder(); + @override + Category deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CategoryBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'name': - result.name = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/class_model.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/class_model.dart index 7fba9383d8b..bdc392005cf 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/class_model.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/class_model.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'class_model.g.dart'; + + abstract class ClassModel implements Built { - @BuiltValueField(wireName: r'_class') - String? get class_; + @BuiltValueField(wireName: r'_class') + String? get class_; - ClassModel._(); + ClassModel._(); - static void _initializeBuilder(ClassModelBuilder b) => b; + static void _initializeBuilder(ClassModelBuilder b) => b; - factory ClassModel([void updates(ClassModelBuilder b)]) = _$ClassModel; + factory ClassModel([void updates(ClassModelBuilder b)]) = _$ClassModel; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ClassModelSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ClassModelSerializer(); } class _$ClassModelSerializer implements StructuredSerializer { - @override - final Iterable types = const [ClassModel, _$ClassModel]; + @override + final Iterable types = const [ClassModel, _$ClassModel]; - @override - final String wireName = r'ClassModel'; + @override + final String wireName = r'ClassModel'; - @override - Iterable serialize(Serializers serializers, ClassModel object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.class_ != null) { - result - ..add(r'_class') - ..add(serializers.serialize(object.class_, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, ClassModel object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.class_ != null) { + result + ..add(r'_class') + ..add(serializers.serialize(object.class_, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - ClassModel deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ClassModelBuilder(); + @override + ClassModel deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ClassModelBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'_class': - result.class_ = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'_class': + result.class_ = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog.dart index f82b0f789b4..63f2d483d5d 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog.dart @@ -12,80 +12,82 @@ part 'dog.g.dart'; // ignore_for_file: unused_import abstract class Dog implements Built { - @BuiltValueField(wireName: r'className') - String get className; + @BuiltValueField(wireName: r'className') + String get className; - @BuiltValueField(wireName: r'color') - String? get color; + @BuiltValueField(wireName: r'color') + String? get color; - @BuiltValueField(wireName: r'breed') - String? get breed; + @BuiltValueField(wireName: r'breed') + String? get breed; - Dog._(); + Dog._(); - static void _initializeBuilder(DogBuilder b) => b..color = 'red'; + static void _initializeBuilder(DogBuilder b) => b + ..color = 'red'; - factory Dog([void updates(DogBuilder b)]) = _$Dog; + factory Dog([void updates(DogBuilder b)]) = _$Dog; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$DogSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$DogSerializer(); } class _$DogSerializer implements StructuredSerializer { - @override - final Iterable types = const [Dog, _$Dog]; + @override + final Iterable types = const [Dog, _$Dog]; - @override - final String wireName = r'Dog'; + @override + final String wireName = r'Dog'; - @override - Iterable serialize(Serializers serializers, Dog object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - result - ..add(r'className') - ..add(serializers.serialize(object.className, - specifiedType: const FullType(String))); - if (object.color != null) { - result - ..add(r'color') - ..add(serializers.serialize(object.color, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, Dog object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + result + ..add(r'className') + ..add(serializers.serialize(object.className, + specifiedType: const FullType(String))); + if (object.color != null) { + result + ..add(r'color') + ..add(serializers.serialize(object.color, + specifiedType: const FullType(String))); + } + if (object.breed != null) { + result + ..add(r'breed') + ..add(serializers.serialize(object.breed, + specifiedType: const FullType(String))); + } + return result; } - if (object.breed != null) { - result - ..add(r'breed') - ..add(serializers.serialize(object.breed, - specifiedType: const FullType(String))); - } - return result; - } - @override - Dog deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = DogBuilder(); + @override + Dog deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = DogBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'className': - result.className = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'color': - result.color = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'breed': - result.breed = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'className': + result.className = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'color': + result.color = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'breed': + result.breed = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog_all_of.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog_all_of.dart index 55bdfa93974..e896ffe4b1b 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog_all_of.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/dog_all_of.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'dog_all_of.g.dart'; + + abstract class DogAllOf implements Built { - @BuiltValueField(wireName: r'breed') - String? get breed; + @BuiltValueField(wireName: r'breed') + String? get breed; - DogAllOf._(); + DogAllOf._(); - static void _initializeBuilder(DogAllOfBuilder b) => b; + static void _initializeBuilder(DogAllOfBuilder b) => b; - factory DogAllOf([void updates(DogAllOfBuilder b)]) = _$DogAllOf; + factory DogAllOf([void updates(DogAllOfBuilder b)]) = _$DogAllOf; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$DogAllOfSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$DogAllOfSerializer(); } class _$DogAllOfSerializer implements StructuredSerializer { - @override - final Iterable types = const [DogAllOf, _$DogAllOf]; + @override + final Iterable types = const [DogAllOf, _$DogAllOf]; - @override - final String wireName = r'DogAllOf'; + @override + final String wireName = r'DogAllOf'; - @override - Iterable serialize(Serializers serializers, DogAllOf object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.breed != null) { - result - ..add(r'breed') - ..add(serializers.serialize(object.breed, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, DogAllOf object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.breed != null) { + result + ..add(r'breed') + ..add(serializers.serialize(object.breed, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - DogAllOf deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = DogAllOfBuilder(); + @override + DogAllOf deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = DogAllOfBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'breed': - result.breed = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'breed': + result.breed = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_arrays.dart index 075c747bd78..371f28947d8 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_arrays.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_arrays.dart @@ -8,112 +8,105 @@ import 'package:built_value/serializer.dart'; part 'enum_arrays.g.dart'; + + abstract class EnumArrays implements Built { - @BuiltValueField(wireName: r'just_symbol') - EnumArraysJustSymbolEnum? get justSymbol; - // enum justSymbolEnum { >=, $, }; + @BuiltValueField(wireName: r'just_symbol') + EnumArraysJustSymbolEnum? get justSymbol; + // enum justSymbolEnum { >=, $, }; - @BuiltValueField(wireName: r'array_enum') - BuiltList? get arrayEnum; - // enum arrayEnumEnum { fish, crab, }; + @BuiltValueField(wireName: r'array_enum') + BuiltList? get arrayEnum; + // enum arrayEnumEnum { fish, crab, }; - EnumArrays._(); + EnumArrays._(); - static void _initializeBuilder(EnumArraysBuilder b) => b; + static void _initializeBuilder(EnumArraysBuilder b) => b; - factory EnumArrays([void updates(EnumArraysBuilder b)]) = _$EnumArrays; + factory EnumArrays([void updates(EnumArraysBuilder b)]) = _$EnumArrays; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$EnumArraysSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$EnumArraysSerializer(); } class _$EnumArraysSerializer implements StructuredSerializer { - @override - final Iterable types = const [EnumArrays, _$EnumArrays]; + @override + final Iterable types = const [EnumArrays, _$EnumArrays]; - @override - final String wireName = r'EnumArrays'; + @override + final String wireName = r'EnumArrays'; - @override - Iterable serialize(Serializers serializers, EnumArrays object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.justSymbol != null) { - result - ..add(r'just_symbol') - ..add(serializers.serialize(object.justSymbol, - specifiedType: const FullType(EnumArraysJustSymbolEnum))); + @override + Iterable serialize(Serializers serializers, EnumArrays object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.justSymbol != null) { + result + ..add(r'just_symbol') + ..add(serializers.serialize(object.justSymbol, + specifiedType: const FullType(EnumArraysJustSymbolEnum))); + } + if (object.arrayEnum != null) { + result + ..add(r'array_enum') + ..add(serializers.serialize(object.arrayEnum, + specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)]))); + } + return result; } - if (object.arrayEnum != null) { - result - ..add(r'array_enum') - ..add(serializers.serialize(object.arrayEnum, - specifiedType: const FullType( - BuiltList, [FullType(EnumArraysArrayEnumEnum)]))); - } - return result; - } - @override - EnumArrays deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = EnumArraysBuilder(); + @override + EnumArrays deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = EnumArraysBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'just_symbol': - result.justSymbol = serializers.deserialize(value, - specifiedType: const FullType(EnumArraysJustSymbolEnum)) - as EnumArraysJustSymbolEnum; - break; - case r'array_enum': - result.arrayEnum.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltList, [FullType(EnumArraysArrayEnumEnum)])) - as BuiltList); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'just_symbol': + result.justSymbol = serializers.deserialize(value, + specifiedType: const FullType(EnumArraysJustSymbolEnum)) as EnumArraysJustSymbolEnum; + break; + case r'array_enum': + result.arrayEnum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(EnumArraysArrayEnumEnum)])) as BuiltList); + break; + } + } + return result.build(); } - return result.build(); - } } class EnumArraysJustSymbolEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'>=') - static const EnumArraysJustSymbolEnum greaterThanEqual = - _$enumArraysJustSymbolEnum_greaterThanEqual; + static const EnumArraysJustSymbolEnum greaterThanEqual = _$enumArraysJustSymbolEnum_greaterThanEqual; @BuiltValueEnumConst(wireName: r'$') - static const EnumArraysJustSymbolEnum dollar = - _$enumArraysJustSymbolEnum_dollar; + static const EnumArraysJustSymbolEnum dollar = _$enumArraysJustSymbolEnum_dollar; - static Serializer get serializer => - _$enumArraysJustSymbolEnumSerializer; + static Serializer get serializer => _$enumArraysJustSymbolEnumSerializer; - const EnumArraysJustSymbolEnum._(String name) : super(name); + const EnumArraysJustSymbolEnum._(String name): super(name); - static BuiltSet get values => - _$enumArraysJustSymbolEnumValues; - static EnumArraysJustSymbolEnum valueOf(String name) => - _$enumArraysJustSymbolEnumValueOf(name); + static BuiltSet get values => _$enumArraysJustSymbolEnumValues; + static EnumArraysJustSymbolEnum valueOf(String name) => _$enumArraysJustSymbolEnumValueOf(name); } class EnumArraysArrayEnumEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'fish') static const EnumArraysArrayEnumEnum fish = _$enumArraysArrayEnumEnum_fish; @BuiltValueEnumConst(wireName: r'crab') static const EnumArraysArrayEnumEnum crab = _$enumArraysArrayEnumEnum_crab; - static Serializer get serializer => - _$enumArraysArrayEnumEnumSerializer; + static Serializer get serializer => _$enumArraysArrayEnumEnumSerializer; - const EnumArraysArrayEnumEnum._(String name) : super(name); + const EnumArraysArrayEnumEnum._(String name): super(name); - static BuiltSet get values => - _$enumArraysArrayEnumEnumValues; - static EnumArraysArrayEnumEnum valueOf(String name) => - _$enumArraysArrayEnumEnumValueOf(name); + static BuiltSet get values => _$enumArraysArrayEnumEnumValues; + static EnumArraysArrayEnumEnum valueOf(String name) => _$enumArraysArrayEnumEnumValueOf(name); } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_test.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_test.dart index 57a733bb20b..51c417dcadd 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_test.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/enum_test.dart @@ -12,166 +12,162 @@ import 'package:built_value/serializer.dart'; part 'enum_test.g.dart'; + + abstract class EnumTest implements Built { - @BuiltValueField(wireName: r'enum_string') - EnumTestEnumStringEnum? get enumString; - // enum enumStringEnum { UPPER, lower, , }; + @BuiltValueField(wireName: r'enum_string') + EnumTestEnumStringEnum? get enumString; + // enum enumStringEnum { UPPER, lower, , }; - @BuiltValueField(wireName: r'enum_string_required') - EnumTestEnumStringRequiredEnum get enumStringRequired; - // enum enumStringRequiredEnum { UPPER, lower, , }; + @BuiltValueField(wireName: r'enum_string_required') + EnumTestEnumStringRequiredEnum get enumStringRequired; + // enum enumStringRequiredEnum { UPPER, lower, , }; - @BuiltValueField(wireName: r'enum_integer') - EnumTestEnumIntegerEnum? get enumInteger; - // enum enumIntegerEnum { 1, -1, }; + @BuiltValueField(wireName: r'enum_integer') + EnumTestEnumIntegerEnum? get enumInteger; + // enum enumIntegerEnum { 1, -1, }; - @BuiltValueField(wireName: r'enum_number') - EnumTestEnumNumberEnum? get enumNumber; - // enum enumNumberEnum { 1.1, -1.2, }; + @BuiltValueField(wireName: r'enum_number') + EnumTestEnumNumberEnum? get enumNumber; + // enum enumNumberEnum { 1.1, -1.2, }; - @BuiltValueField(wireName: r'outerEnum') - OuterEnum? get outerEnum; - // enum outerEnumEnum { placed, approved, delivered, }; + @BuiltValueField(wireName: r'outerEnum') + OuterEnum? get outerEnum; + // enum outerEnumEnum { placed, approved, delivered, }; - @BuiltValueField(wireName: r'outerEnumInteger') - OuterEnumInteger? get outerEnumInteger; - // enum outerEnumIntegerEnum { 0, 1, 2, }; + @BuiltValueField(wireName: r'outerEnumInteger') + OuterEnumInteger? get outerEnumInteger; + // enum outerEnumIntegerEnum { 0, 1, 2, }; - @BuiltValueField(wireName: r'outerEnumDefaultValue') - OuterEnumDefaultValue? get outerEnumDefaultValue; - // enum outerEnumDefaultValueEnum { placed, approved, delivered, }; + @BuiltValueField(wireName: r'outerEnumDefaultValue') + OuterEnumDefaultValue? get outerEnumDefaultValue; + // enum outerEnumDefaultValueEnum { placed, approved, delivered, }; - @BuiltValueField(wireName: r'outerEnumIntegerDefaultValue') - OuterEnumIntegerDefaultValue? get outerEnumIntegerDefaultValue; - // enum outerEnumIntegerDefaultValueEnum { 0, 1, 2, }; + @BuiltValueField(wireName: r'outerEnumIntegerDefaultValue') + OuterEnumIntegerDefaultValue? get outerEnumIntegerDefaultValue; + // enum outerEnumIntegerDefaultValueEnum { 0, 1, 2, }; - EnumTest._(); + EnumTest._(); - static void _initializeBuilder(EnumTestBuilder b) => b; + static void _initializeBuilder(EnumTestBuilder b) => b; - factory EnumTest([void updates(EnumTestBuilder b)]) = _$EnumTest; + factory EnumTest([void updates(EnumTestBuilder b)]) = _$EnumTest; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$EnumTestSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$EnumTestSerializer(); } class _$EnumTestSerializer implements StructuredSerializer { - @override - final Iterable types = const [EnumTest, _$EnumTest]; + @override + final Iterable types = const [EnumTest, _$EnumTest]; - @override - final String wireName = r'EnumTest'; + @override + final String wireName = r'EnumTest'; - @override - Iterable serialize(Serializers serializers, EnumTest object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.enumString != null) { - result - ..add(r'enum_string') - ..add(serializers.serialize(object.enumString, - specifiedType: const FullType(EnumTestEnumStringEnum))); + @override + Iterable serialize(Serializers serializers, EnumTest object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.enumString != null) { + result + ..add(r'enum_string') + ..add(serializers.serialize(object.enumString, + specifiedType: const FullType(EnumTestEnumStringEnum))); + } + result + ..add(r'enum_string_required') + ..add(serializers.serialize(object.enumStringRequired, + specifiedType: const FullType(EnumTestEnumStringRequiredEnum))); + if (object.enumInteger != null) { + result + ..add(r'enum_integer') + ..add(serializers.serialize(object.enumInteger, + specifiedType: const FullType(EnumTestEnumIntegerEnum))); + } + if (object.enumNumber != null) { + result + ..add(r'enum_number') + ..add(serializers.serialize(object.enumNumber, + specifiedType: const FullType(EnumTestEnumNumberEnum))); + } + if (object.outerEnum != null) { + result + ..add(r'outerEnum') + ..add(serializers.serialize(object.outerEnum, + specifiedType: const FullType(OuterEnum))); + } + if (object.outerEnumInteger != null) { + result + ..add(r'outerEnumInteger') + ..add(serializers.serialize(object.outerEnumInteger, + specifiedType: const FullType(OuterEnumInteger))); + } + if (object.outerEnumDefaultValue != null) { + result + ..add(r'outerEnumDefaultValue') + ..add(serializers.serialize(object.outerEnumDefaultValue, + specifiedType: const FullType(OuterEnumDefaultValue))); + } + if (object.outerEnumIntegerDefaultValue != null) { + result + ..add(r'outerEnumIntegerDefaultValue') + ..add(serializers.serialize(object.outerEnumIntegerDefaultValue, + specifiedType: const FullType(OuterEnumIntegerDefaultValue))); + } + return result; } - result - ..add(r'enum_string_required') - ..add(serializers.serialize(object.enumStringRequired, - specifiedType: const FullType(EnumTestEnumStringRequiredEnum))); - if (object.enumInteger != null) { - result - ..add(r'enum_integer') - ..add(serializers.serialize(object.enumInteger, - specifiedType: const FullType(EnumTestEnumIntegerEnum))); - } - if (object.enumNumber != null) { - result - ..add(r'enum_number') - ..add(serializers.serialize(object.enumNumber, - specifiedType: const FullType(EnumTestEnumNumberEnum))); - } - if (object.outerEnum != null) { - result - ..add(r'outerEnum') - ..add(serializers.serialize(object.outerEnum, - specifiedType: const FullType(OuterEnum))); - } - if (object.outerEnumInteger != null) { - result - ..add(r'outerEnumInteger') - ..add(serializers.serialize(object.outerEnumInteger, - specifiedType: const FullType(OuterEnumInteger))); - } - if (object.outerEnumDefaultValue != null) { - result - ..add(r'outerEnumDefaultValue') - ..add(serializers.serialize(object.outerEnumDefaultValue, - specifiedType: const FullType(OuterEnumDefaultValue))); - } - if (object.outerEnumIntegerDefaultValue != null) { - result - ..add(r'outerEnumIntegerDefaultValue') - ..add(serializers.serialize(object.outerEnumIntegerDefaultValue, - specifiedType: const FullType(OuterEnumIntegerDefaultValue))); - } - return result; - } - @override - EnumTest deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = EnumTestBuilder(); + @override + EnumTest deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = EnumTestBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'enum_string': - result.enumString = serializers.deserialize(value, - specifiedType: const FullType(EnumTestEnumStringEnum)) - as EnumTestEnumStringEnum; - break; - case r'enum_string_required': - result.enumStringRequired = serializers.deserialize(value, - specifiedType: const FullType(EnumTestEnumStringRequiredEnum)) - as EnumTestEnumStringRequiredEnum; - break; - case r'enum_integer': - result.enumInteger = serializers.deserialize(value, - specifiedType: const FullType(EnumTestEnumIntegerEnum)) - as EnumTestEnumIntegerEnum; - break; - case r'enum_number': - result.enumNumber = serializers.deserialize(value, - specifiedType: const FullType(EnumTestEnumNumberEnum)) - as EnumTestEnumNumberEnum; - break; - case r'outerEnum': - result.outerEnum = serializers.deserialize(value, - specifiedType: const FullType(OuterEnum)) as OuterEnum; - break; - case r'outerEnumInteger': - result.outerEnumInteger = serializers.deserialize(value, - specifiedType: const FullType(OuterEnumInteger)) - as OuterEnumInteger; - break; - case r'outerEnumDefaultValue': - result.outerEnumDefaultValue = serializers.deserialize(value, - specifiedType: const FullType(OuterEnumDefaultValue)) - as OuterEnumDefaultValue; - break; - case r'outerEnumIntegerDefaultValue': - result.outerEnumIntegerDefaultValue = serializers.deserialize(value, - specifiedType: const FullType(OuterEnumIntegerDefaultValue)) - as OuterEnumIntegerDefaultValue; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'enum_string': + result.enumString = serializers.deserialize(value, + specifiedType: const FullType(EnumTestEnumStringEnum)) as EnumTestEnumStringEnum; + break; + case r'enum_string_required': + result.enumStringRequired = serializers.deserialize(value, + specifiedType: const FullType(EnumTestEnumStringRequiredEnum)) as EnumTestEnumStringRequiredEnum; + break; + case r'enum_integer': + result.enumInteger = serializers.deserialize(value, + specifiedType: const FullType(EnumTestEnumIntegerEnum)) as EnumTestEnumIntegerEnum; + break; + case r'enum_number': + result.enumNumber = serializers.deserialize(value, + specifiedType: const FullType(EnumTestEnumNumberEnum)) as EnumTestEnumNumberEnum; + break; + case r'outerEnum': + result.outerEnum = serializers.deserialize(value, + specifiedType: const FullType(OuterEnum)) as OuterEnum; + break; + case r'outerEnumInteger': + result.outerEnumInteger = serializers.deserialize(value, + specifiedType: const FullType(OuterEnumInteger)) as OuterEnumInteger; + break; + case r'outerEnumDefaultValue': + result.outerEnumDefaultValue = serializers.deserialize(value, + specifiedType: const FullType(OuterEnumDefaultValue)) as OuterEnumDefaultValue; + break; + case r'outerEnumIntegerDefaultValue': + result.outerEnumIntegerDefaultValue = serializers.deserialize(value, + specifiedType: const FullType(OuterEnumIntegerDefaultValue)) as OuterEnumIntegerDefaultValue; + break; + } + } + return result.build(); } - return result.build(); - } } class EnumTestEnumStringEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'UPPER') static const EnumTestEnumStringEnum UPPER = _$enumTestEnumStringEnum_UPPER; @BuiltValueEnumConst(wireName: r'lower') @@ -179,73 +175,58 @@ class EnumTestEnumStringEnum extends EnumClass { @BuiltValueEnumConst(wireName: r'') static const EnumTestEnumStringEnum empty = _$enumTestEnumStringEnum_empty; - static Serializer get serializer => - _$enumTestEnumStringEnumSerializer; + static Serializer get serializer => _$enumTestEnumStringEnumSerializer; - const EnumTestEnumStringEnum._(String name) : super(name); + const EnumTestEnumStringEnum._(String name): super(name); - static BuiltSet get values => - _$enumTestEnumStringEnumValues; - static EnumTestEnumStringEnum valueOf(String name) => - _$enumTestEnumStringEnumValueOf(name); + static BuiltSet get values => _$enumTestEnumStringEnumValues; + static EnumTestEnumStringEnum valueOf(String name) => _$enumTestEnumStringEnumValueOf(name); } class EnumTestEnumStringRequiredEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'UPPER') - static const EnumTestEnumStringRequiredEnum UPPER = - _$enumTestEnumStringRequiredEnum_UPPER; + static const EnumTestEnumStringRequiredEnum UPPER = _$enumTestEnumStringRequiredEnum_UPPER; @BuiltValueEnumConst(wireName: r'lower') - static const EnumTestEnumStringRequiredEnum lower = - _$enumTestEnumStringRequiredEnum_lower; + static const EnumTestEnumStringRequiredEnum lower = _$enumTestEnumStringRequiredEnum_lower; @BuiltValueEnumConst(wireName: r'') - static const EnumTestEnumStringRequiredEnum empty = - _$enumTestEnumStringRequiredEnum_empty; + static const EnumTestEnumStringRequiredEnum empty = _$enumTestEnumStringRequiredEnum_empty; - static Serializer get serializer => - _$enumTestEnumStringRequiredEnumSerializer; + static Serializer get serializer => _$enumTestEnumStringRequiredEnumSerializer; - const EnumTestEnumStringRequiredEnum._(String name) : super(name); + const EnumTestEnumStringRequiredEnum._(String name): super(name); - static BuiltSet get values => - _$enumTestEnumStringRequiredEnumValues; - static EnumTestEnumStringRequiredEnum valueOf(String name) => - _$enumTestEnumStringRequiredEnumValueOf(name); + static BuiltSet get values => _$enumTestEnumStringRequiredEnumValues; + static EnumTestEnumStringRequiredEnum valueOf(String name) => _$enumTestEnumStringRequiredEnumValueOf(name); } class EnumTestEnumIntegerEnum extends EnumClass { + @BuiltValueEnumConst(wireNumber: 1) - static const EnumTestEnumIntegerEnum number1 = - _$enumTestEnumIntegerEnum_number1; + static const EnumTestEnumIntegerEnum number1 = _$enumTestEnumIntegerEnum_number1; @BuiltValueEnumConst(wireNumber: -1) - static const EnumTestEnumIntegerEnum numberNegative1 = - _$enumTestEnumIntegerEnum_numberNegative1; + static const EnumTestEnumIntegerEnum numberNegative1 = _$enumTestEnumIntegerEnum_numberNegative1; - static Serializer get serializer => - _$enumTestEnumIntegerEnumSerializer; + static Serializer get serializer => _$enumTestEnumIntegerEnumSerializer; - const EnumTestEnumIntegerEnum._(String name) : super(name); + const EnumTestEnumIntegerEnum._(String name): super(name); - static BuiltSet get values => - _$enumTestEnumIntegerEnumValues; - static EnumTestEnumIntegerEnum valueOf(String name) => - _$enumTestEnumIntegerEnumValueOf(name); + static BuiltSet get values => _$enumTestEnumIntegerEnumValues; + static EnumTestEnumIntegerEnum valueOf(String name) => _$enumTestEnumIntegerEnumValueOf(name); } class EnumTestEnumNumberEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'1.1') - static const EnumTestEnumNumberEnum number1Period1 = - _$enumTestEnumNumberEnum_number1Period1; + static const EnumTestEnumNumberEnum number1Period1 = _$enumTestEnumNumberEnum_number1Period1; @BuiltValueEnumConst(wireName: r'-1.2') - static const EnumTestEnumNumberEnum numberNegative1Period2 = - _$enumTestEnumNumberEnum_numberNegative1Period2; + static const EnumTestEnumNumberEnum numberNegative1Period2 = _$enumTestEnumNumberEnum_numberNegative1Period2; - static Serializer get serializer => - _$enumTestEnumNumberEnumSerializer; + static Serializer get serializer => _$enumTestEnumNumberEnumSerializer; - const EnumTestEnumNumberEnum._(String name) : super(name); + const EnumTestEnumNumberEnum._(String name): super(name); - static BuiltSet get values => - _$enumTestEnumNumberEnumValues; - static EnumTestEnumNumberEnum valueOf(String name) => - _$enumTestEnumNumberEnumValueOf(name); + static BuiltSet get values => _$enumTestEnumNumberEnumValues; + static EnumTestEnumNumberEnum valueOf(String name) => _$enumTestEnumNumberEnumValueOf(name); } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart index 78771ae4097..083b61e326a 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/file_schema_test_class.dart @@ -9,81 +9,73 @@ import 'package:built_value/serializer.dart'; part 'file_schema_test_class.g.dart'; -abstract class FileSchemaTestClass - implements Built { - @BuiltValueField(wireName: r'file') - ModelFile? get file; - @BuiltValueField(wireName: r'files') - BuiltList? get files; - FileSchemaTestClass._(); +abstract class FileSchemaTestClass implements Built { + @BuiltValueField(wireName: r'file') + ModelFile? get file; - static void _initializeBuilder(FileSchemaTestClassBuilder b) => b; + @BuiltValueField(wireName: r'files') + BuiltList? get files; - factory FileSchemaTestClass([void updates(FileSchemaTestClassBuilder b)]) = - _$FileSchemaTestClass; + FileSchemaTestClass._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$FileSchemaTestClassSerializer(); + static void _initializeBuilder(FileSchemaTestClassBuilder b) => b; + + factory FileSchemaTestClass([void updates(FileSchemaTestClassBuilder b)]) = _$FileSchemaTestClass; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$FileSchemaTestClassSerializer(); } -class _$FileSchemaTestClassSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - FileSchemaTestClass, - _$FileSchemaTestClass - ]; +class _$FileSchemaTestClassSerializer implements StructuredSerializer { + @override + final Iterable types = const [FileSchemaTestClass, _$FileSchemaTestClass]; - @override - final String wireName = r'FileSchemaTestClass'; + @override + final String wireName = r'FileSchemaTestClass'; - @override - Iterable serialize( - Serializers serializers, FileSchemaTestClass object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.file != null) { - result - ..add(r'file') - ..add(serializers.serialize(object.file, - specifiedType: const FullType(ModelFile))); + @override + Iterable serialize(Serializers serializers, FileSchemaTestClass object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.file != null) { + result + ..add(r'file') + ..add(serializers.serialize(object.file, + specifiedType: const FullType(ModelFile))); + } + if (object.files != null) { + result + ..add(r'files') + ..add(serializers.serialize(object.files, + specifiedType: const FullType(BuiltList, [FullType(ModelFile)]))); + } + return result; } - if (object.files != null) { - result - ..add(r'files') - ..add(serializers.serialize(object.files, - specifiedType: const FullType(BuiltList, [FullType(ModelFile)]))); - } - return result; - } - @override - FileSchemaTestClass deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = FileSchemaTestClassBuilder(); + @override + FileSchemaTestClass deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = FileSchemaTestClassBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'file': - result.file.replace(serializers.deserialize(value, - specifiedType: const FullType(ModelFile)) as ModelFile); - break; - case r'files': - result.files.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, [FullType(ModelFile)])) - as BuiltList); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'file': + result.file.replace(serializers.deserialize(value, + specifiedType: const FullType(ModelFile)) as ModelFile); + break; + case r'files': + result.files.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(ModelFile)])) as BuiltList); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/foo.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/foo.dart index 5c7a4f9fe84..045d8857577 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/foo.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/foo.dart @@ -7,57 +7,61 @@ import 'package:built_value/serializer.dart'; part 'foo.g.dart'; + + abstract class Foo implements Built { - @BuiltValueField(wireName: r'bar') - String? get bar; + @BuiltValueField(wireName: r'bar') + String? get bar; - Foo._(); + Foo._(); - static void _initializeBuilder(FooBuilder b) => b..bar = 'bar'; + static void _initializeBuilder(FooBuilder b) => b + ..bar = 'bar'; - factory Foo([void updates(FooBuilder b)]) = _$Foo; + factory Foo([void updates(FooBuilder b)]) = _$Foo; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$FooSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$FooSerializer(); } class _$FooSerializer implements StructuredSerializer { - @override - final Iterable types = const [Foo, _$Foo]; + @override + final Iterable types = const [Foo, _$Foo]; - @override - final String wireName = r'Foo'; + @override + final String wireName = r'Foo'; - @override - Iterable serialize(Serializers serializers, Foo object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.bar != null) { - result - ..add(r'bar') - ..add(serializers.serialize(object.bar, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, Foo object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.bar != null) { + result + ..add(r'bar') + ..add(serializers.serialize(object.bar, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - Foo deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = FooBuilder(); + @override + Foo deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = FooBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'bar': - result.bar = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'bar': + result.bar = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/format_test.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/format_test.dart index 45d02a32804..60879a1479a 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/format_test.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/format_test.dart @@ -8,246 +8,249 @@ import 'package:built_value/serializer.dart'; part 'format_test.g.dart'; + + abstract class FormatTest implements Built { - @BuiltValueField(wireName: r'integer') - int? get integer; + @BuiltValueField(wireName: r'integer') + int? get integer; - @BuiltValueField(wireName: r'int32') - int? get int32; + @BuiltValueField(wireName: r'int32') + int? get int32; - @BuiltValueField(wireName: r'int64') - int? get int64; + @BuiltValueField(wireName: r'int64') + int? get int64; - @BuiltValueField(wireName: r'number') - num get number; + @BuiltValueField(wireName: r'number') + num get number; - @BuiltValueField(wireName: r'float') - double? get float; + @BuiltValueField(wireName: r'float') + double? get float; - @BuiltValueField(wireName: r'double') - double? get double_; + @BuiltValueField(wireName: r'double') + double? get double_; - @BuiltValueField(wireName: r'decimal') - double? get decimal; + @BuiltValueField(wireName: r'decimal') + double? get decimal; - @BuiltValueField(wireName: r'string') - String? get string; + @BuiltValueField(wireName: r'string') + String? get string; - @BuiltValueField(wireName: r'byte') - String get byte; + @BuiltValueField(wireName: r'byte') + String get byte; - @BuiltValueField(wireName: r'binary') - Uint8List? get binary; + @BuiltValueField(wireName: r'binary') + Uint8List? get binary; - @BuiltValueField(wireName: r'date') - DateTime get date; + @BuiltValueField(wireName: r'date') + DateTime get date; - @BuiltValueField(wireName: r'dateTime') - DateTime? get dateTime; + @BuiltValueField(wireName: r'dateTime') + DateTime? get dateTime; - @BuiltValueField(wireName: r'uuid') - String? get uuid; + @BuiltValueField(wireName: r'uuid') + String? get uuid; - @BuiltValueField(wireName: r'password') - String get password; + @BuiltValueField(wireName: r'password') + String get password; - /// A string that is a 10 digit number. Can have leading zeros. - @BuiltValueField(wireName: r'pattern_with_digits') - String? get patternWithDigits; + /// A string that is a 10 digit number. Can have leading zeros. + @BuiltValueField(wireName: r'pattern_with_digits') + String? get patternWithDigits; - /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - @BuiltValueField(wireName: r'pattern_with_digits_and_delimiter') - String? get patternWithDigitsAndDelimiter; + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + @BuiltValueField(wireName: r'pattern_with_digits_and_delimiter') + String? get patternWithDigitsAndDelimiter; - FormatTest._(); + FormatTest._(); - static void _initializeBuilder(FormatTestBuilder b) => b; + static void _initializeBuilder(FormatTestBuilder b) => b; - factory FormatTest([void updates(FormatTestBuilder b)]) = _$FormatTest; + factory FormatTest([void updates(FormatTestBuilder b)]) = _$FormatTest; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$FormatTestSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$FormatTestSerializer(); } class _$FormatTestSerializer implements StructuredSerializer { - @override - final Iterable types = const [FormatTest, _$FormatTest]; + @override + final Iterable types = const [FormatTest, _$FormatTest]; - @override - final String wireName = r'FormatTest'; + @override + final String wireName = r'FormatTest'; - @override - Iterable serialize(Serializers serializers, FormatTest object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.integer != null) { - result - ..add(r'integer') - ..add(serializers.serialize(object.integer, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, FormatTest object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.integer != null) { + result + ..add(r'integer') + ..add(serializers.serialize(object.integer, + specifiedType: const FullType(int))); + } + if (object.int32 != null) { + result + ..add(r'int32') + ..add(serializers.serialize(object.int32, + specifiedType: const FullType(int))); + } + if (object.int64 != null) { + result + ..add(r'int64') + ..add(serializers.serialize(object.int64, + specifiedType: const FullType(int))); + } + result + ..add(r'number') + ..add(serializers.serialize(object.number, + specifiedType: const FullType(num))); + if (object.float != null) { + result + ..add(r'float') + ..add(serializers.serialize(object.float, + specifiedType: const FullType(double))); + } + if (object.double_ != null) { + result + ..add(r'double') + ..add(serializers.serialize(object.double_, + specifiedType: const FullType(double))); + } + if (object.decimal != null) { + result + ..add(r'decimal') + ..add(serializers.serialize(object.decimal, + specifiedType: const FullType(double))); + } + if (object.string != null) { + result + ..add(r'string') + ..add(serializers.serialize(object.string, + specifiedType: const FullType(String))); + } + result + ..add(r'byte') + ..add(serializers.serialize(object.byte, + specifiedType: const FullType(String))); + if (object.binary != null) { + result + ..add(r'binary') + ..add(serializers.serialize(object.binary, + specifiedType: const FullType(Uint8List))); + } + result + ..add(r'date') + ..add(serializers.serialize(object.date, + specifiedType: const FullType(DateTime))); + if (object.dateTime != null) { + result + ..add(r'dateTime') + ..add(serializers.serialize(object.dateTime, + specifiedType: const FullType(DateTime))); + } + if (object.uuid != null) { + result + ..add(r'uuid') + ..add(serializers.serialize(object.uuid, + specifiedType: const FullType(String))); + } + result + ..add(r'password') + ..add(serializers.serialize(object.password, + specifiedType: const FullType(String))); + if (object.patternWithDigits != null) { + result + ..add(r'pattern_with_digits') + ..add(serializers.serialize(object.patternWithDigits, + specifiedType: const FullType(String))); + } + if (object.patternWithDigitsAndDelimiter != null) { + result + ..add(r'pattern_with_digits_and_delimiter') + ..add(serializers.serialize(object.patternWithDigitsAndDelimiter, + specifiedType: const FullType(String))); + } + return result; } - if (object.int32 != null) { - result - ..add(r'int32') - ..add(serializers.serialize(object.int32, - specifiedType: const FullType(int))); - } - if (object.int64 != null) { - result - ..add(r'int64') - ..add(serializers.serialize(object.int64, - specifiedType: const FullType(int))); - } - result - ..add(r'number') - ..add(serializers.serialize(object.number, - specifiedType: const FullType(num))); - if (object.float != null) { - result - ..add(r'float') - ..add(serializers.serialize(object.float, - specifiedType: const FullType(double))); - } - if (object.double_ != null) { - result - ..add(r'double') - ..add(serializers.serialize(object.double_, - specifiedType: const FullType(double))); - } - if (object.decimal != null) { - result - ..add(r'decimal') - ..add(serializers.serialize(object.decimal, - specifiedType: const FullType(double))); - } - if (object.string != null) { - result - ..add(r'string') - ..add(serializers.serialize(object.string, - specifiedType: const FullType(String))); - } - result - ..add(r'byte') - ..add(serializers.serialize(object.byte, - specifiedType: const FullType(String))); - if (object.binary != null) { - result - ..add(r'binary') - ..add(serializers.serialize(object.binary, - specifiedType: const FullType(Uint8List))); - } - result - ..add(r'date') - ..add(serializers.serialize(object.date, - specifiedType: const FullType(DateTime))); - if (object.dateTime != null) { - result - ..add(r'dateTime') - ..add(serializers.serialize(object.dateTime, - specifiedType: const FullType(DateTime))); - } - if (object.uuid != null) { - result - ..add(r'uuid') - ..add(serializers.serialize(object.uuid, - specifiedType: const FullType(String))); - } - result - ..add(r'password') - ..add(serializers.serialize(object.password, - specifiedType: const FullType(String))); - if (object.patternWithDigits != null) { - result - ..add(r'pattern_with_digits') - ..add(serializers.serialize(object.patternWithDigits, - specifiedType: const FullType(String))); - } - if (object.patternWithDigitsAndDelimiter != null) { - result - ..add(r'pattern_with_digits_and_delimiter') - ..add(serializers.serialize(object.patternWithDigitsAndDelimiter, - specifiedType: const FullType(String))); - } - return result; - } - @override - FormatTest deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = FormatTestBuilder(); + @override + FormatTest deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = FormatTestBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'integer': - result.integer = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'int32': - result.int32 = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'int64': - result.int64 = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'number': - result.number = serializers.deserialize(value, - specifiedType: const FullType(num)) as num; - break; - case r'float': - result.float = serializers.deserialize(value, - specifiedType: const FullType(double)) as double; - break; - case r'double': - result.double_ = serializers.deserialize(value, - specifiedType: const FullType(double)) as double; - break; - case r'decimal': - result.decimal = serializers.deserialize(value, - specifiedType: const FullType(double)) as double; - break; - case r'string': - result.string = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'byte': - result.byte = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'binary': - result.binary = serializers.deserialize(value, - specifiedType: const FullType(Uint8List)) as Uint8List; - break; - case r'date': - result.date = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'dateTime': - result.dateTime = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'uuid': - result.uuid = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'password': - result.password = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'pattern_with_digits': - result.patternWithDigits = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'pattern_with_digits_and_delimiter': - result.patternWithDigitsAndDelimiter = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'integer': + result.integer = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'int32': + result.int32 = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'int64': + result.int64 = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'number': + result.number = serializers.deserialize(value, + specifiedType: const FullType(num)) as num; + break; + case r'float': + result.float = serializers.deserialize(value, + specifiedType: const FullType(double)) as double; + break; + case r'double': + result.double_ = serializers.deserialize(value, + specifiedType: const FullType(double)) as double; + break; + case r'decimal': + result.decimal = serializers.deserialize(value, + specifiedType: const FullType(double)) as double; + break; + case r'string': + result.string = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'byte': + result.byte = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'binary': + result.binary = serializers.deserialize(value, + specifiedType: const FullType(Uint8List)) as Uint8List; + break; + case r'date': + result.date = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'dateTime': + result.dateTime = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'uuid': + result.uuid = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'password': + result.password = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'pattern_with_digits': + result.patternWithDigits = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'pattern_with_digits_and_delimiter': + result.patternWithDigitsAndDelimiter = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart index 783ada10239..f7cb2cd2e5a 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/has_only_read_only.dart @@ -7,75 +7,73 @@ import 'package:built_value/serializer.dart'; part 'has_only_read_only.g.dart'; -abstract class HasOnlyReadOnly - implements Built { - @BuiltValueField(wireName: r'bar') - String? get bar; - @BuiltValueField(wireName: r'foo') - String? get foo; - HasOnlyReadOnly._(); +abstract class HasOnlyReadOnly implements Built { + @BuiltValueField(wireName: r'bar') + String? get bar; - static void _initializeBuilder(HasOnlyReadOnlyBuilder b) => b; + @BuiltValueField(wireName: r'foo') + String? get foo; - factory HasOnlyReadOnly([void updates(HasOnlyReadOnlyBuilder b)]) = - _$HasOnlyReadOnly; + HasOnlyReadOnly._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$HasOnlyReadOnlySerializer(); + static void _initializeBuilder(HasOnlyReadOnlyBuilder b) => b; + + factory HasOnlyReadOnly([void updates(HasOnlyReadOnlyBuilder b)]) = _$HasOnlyReadOnly; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$HasOnlyReadOnlySerializer(); } -class _$HasOnlyReadOnlySerializer - implements StructuredSerializer { - @override - final Iterable types = const [HasOnlyReadOnly, _$HasOnlyReadOnly]; +class _$HasOnlyReadOnlySerializer implements StructuredSerializer { + @override + final Iterable types = const [HasOnlyReadOnly, _$HasOnlyReadOnly]; - @override - final String wireName = r'HasOnlyReadOnly'; + @override + final String wireName = r'HasOnlyReadOnly'; - @override - Iterable serialize(Serializers serializers, HasOnlyReadOnly object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.bar != null) { - result - ..add(r'bar') - ..add(serializers.serialize(object.bar, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, HasOnlyReadOnly object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.bar != null) { + result + ..add(r'bar') + ..add(serializers.serialize(object.bar, + specifiedType: const FullType(String))); + } + if (object.foo != null) { + result + ..add(r'foo') + ..add(serializers.serialize(object.foo, + specifiedType: const FullType(String))); + } + return result; } - if (object.foo != null) { - result - ..add(r'foo') - ..add(serializers.serialize(object.foo, - specifiedType: const FullType(String))); - } - return result; - } - @override - HasOnlyReadOnly deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = HasOnlyReadOnlyBuilder(); + @override + HasOnlyReadOnly deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = HasOnlyReadOnlyBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'bar': - result.bar = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'foo': - result.foo = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'bar': + result.bar = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'foo': + result.foo = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/health_check_result.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/health_check_result.dart index 8fb18b9e352..69bca6dce0f 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/health_check_result.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/health_check_result.dart @@ -7,62 +7,60 @@ import 'package:built_value/serializer.dart'; part 'health_check_result.g.dart'; -abstract class HealthCheckResult - implements Built { - @BuiltValueField(wireName: r'NullableMessage') - String? get nullableMessage; - HealthCheckResult._(); - static void _initializeBuilder(HealthCheckResultBuilder b) => b; +abstract class HealthCheckResult implements Built { + @BuiltValueField(wireName: r'NullableMessage') + String? get nullableMessage; - factory HealthCheckResult([void updates(HealthCheckResultBuilder b)]) = - _$HealthCheckResult; + HealthCheckResult._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$HealthCheckResultSerializer(); + static void _initializeBuilder(HealthCheckResultBuilder b) => b; + + factory HealthCheckResult([void updates(HealthCheckResultBuilder b)]) = _$HealthCheckResult; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$HealthCheckResultSerializer(); } -class _$HealthCheckResultSerializer - implements StructuredSerializer { - @override - final Iterable types = const [HealthCheckResult, _$HealthCheckResult]; +class _$HealthCheckResultSerializer implements StructuredSerializer { + @override + final Iterable types = const [HealthCheckResult, _$HealthCheckResult]; - @override - final String wireName = r'HealthCheckResult'; + @override + final String wireName = r'HealthCheckResult'; - @override - Iterable serialize(Serializers serializers, HealthCheckResult object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.nullableMessage != null) { - result - ..add(r'NullableMessage') - ..add(serializers.serialize(object.nullableMessage, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, HealthCheckResult object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.nullableMessage != null) { + result + ..add(r'NullableMessage') + ..add(serializers.serialize(object.nullableMessage, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - HealthCheckResult deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = HealthCheckResultBuilder(); + @override + HealthCheckResult deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = HealthCheckResultBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'NullableMessage': - result.nullableMessage = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'NullableMessage': + result.nullableMessage = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/inline_response_default.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/inline_response_default.dart index be622a53992..875b612c5d6 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/inline_response_default.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/inline_response_default.dart @@ -8,66 +8,60 @@ import 'package:built_value/serializer.dart'; part 'inline_response_default.g.dart'; -abstract class InlineResponseDefault - implements Built { - @BuiltValueField(wireName: r'string') - Foo? get string; - InlineResponseDefault._(); - static void _initializeBuilder(InlineResponseDefaultBuilder b) => b; +abstract class InlineResponseDefault implements Built { + @BuiltValueField(wireName: r'string') + Foo? get string; - factory InlineResponseDefault( - [void updates(InlineResponseDefaultBuilder b)]) = _$InlineResponseDefault; + InlineResponseDefault._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$InlineResponseDefaultSerializer(); + static void _initializeBuilder(InlineResponseDefaultBuilder b) => b; + + factory InlineResponseDefault([void updates(InlineResponseDefaultBuilder b)]) = _$InlineResponseDefault; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$InlineResponseDefaultSerializer(); } -class _$InlineResponseDefaultSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - InlineResponseDefault, - _$InlineResponseDefault - ]; +class _$InlineResponseDefaultSerializer implements StructuredSerializer { + @override + final Iterable types = const [InlineResponseDefault, _$InlineResponseDefault]; - @override - final String wireName = r'InlineResponseDefault'; + @override + final String wireName = r'InlineResponseDefault'; - @override - Iterable serialize( - Serializers serializers, InlineResponseDefault object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.string != null) { - result - ..add(r'string') - ..add(serializers.serialize(object.string, - specifiedType: const FullType(Foo))); + @override + Iterable serialize(Serializers serializers, InlineResponseDefault object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.string != null) { + result + ..add(r'string') + ..add(serializers.serialize(object.string, + specifiedType: const FullType(Foo))); + } + return result; } - return result; - } - @override - InlineResponseDefault deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = InlineResponseDefaultBuilder(); + @override + InlineResponseDefault deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = InlineResponseDefaultBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'string': - result.string.replace(serializers.deserialize(value, - specifiedType: const FullType(Foo)) as Foo); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'string': + result.string.replace(serializers.deserialize(value, + specifiedType: const FullType(Foo)) as Foo); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/map_test.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/map_test.dart index 68ea560bbb7..21af21a52bb 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/map_test.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/map_test.dart @@ -8,132 +8,115 @@ import 'package:built_value/serializer.dart'; part 'map_test.g.dart'; + + abstract class MapTest implements Built { - @BuiltValueField(wireName: r'map_map_of_string') - BuiltMap>? get mapMapOfString; + @BuiltValueField(wireName: r'map_map_of_string') + BuiltMap>? get mapMapOfString; - @BuiltValueField(wireName: r'map_of_enum_string') - BuiltMap? get mapOfEnumString; - // enum mapOfEnumStringEnum { UPPER, lower, }; + @BuiltValueField(wireName: r'map_of_enum_string') + BuiltMap? get mapOfEnumString; + // enum mapOfEnumStringEnum { UPPER, lower, }; - @BuiltValueField(wireName: r'direct_map') - BuiltMap? get directMap; + @BuiltValueField(wireName: r'direct_map') + BuiltMap? get directMap; - @BuiltValueField(wireName: r'indirect_map') - BuiltMap? get indirectMap; + @BuiltValueField(wireName: r'indirect_map') + BuiltMap? get indirectMap; - MapTest._(); + MapTest._(); - static void _initializeBuilder(MapTestBuilder b) => b; + static void _initializeBuilder(MapTestBuilder b) => b; - factory MapTest([void updates(MapTestBuilder b)]) = _$MapTest; + factory MapTest([void updates(MapTestBuilder b)]) = _$MapTest; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$MapTestSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$MapTestSerializer(); } class _$MapTestSerializer implements StructuredSerializer { - @override - final Iterable types = const [MapTest, _$MapTest]; + @override + final Iterable types = const [MapTest, _$MapTest]; - @override - final String wireName = r'MapTest'; + @override + final String wireName = r'MapTest'; - @override - Iterable serialize(Serializers serializers, MapTest object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.mapMapOfString != null) { - result - ..add(r'map_map_of_string') - ..add(serializers.serialize(object.mapMapOfString, - specifiedType: const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltMap, [FullType(String), FullType(String)]) - ]))); + @override + Iterable serialize(Serializers serializers, MapTest object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.mapMapOfString != null) { + result + ..add(r'map_map_of_string') + ..add(serializers.serialize(object.mapMapOfString, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])]))); + } + if (object.mapOfEnumString != null) { + result + ..add(r'map_of_enum_string') + ..add(serializers.serialize(object.mapOfEnumString, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)]))); + } + if (object.directMap != null) { + result + ..add(r'direct_map') + ..add(serializers.serialize(object.directMap, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]))); + } + if (object.indirectMap != null) { + result + ..add(r'indirect_map') + ..add(serializers.serialize(object.indirectMap, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)]))); + } + return result; } - if (object.mapOfEnumString != null) { - result - ..add(r'map_of_enum_string') - ..add(serializers.serialize(object.mapOfEnumString, - specifiedType: const FullType(BuiltMap, - [FullType(String), FullType(MapTestMapOfEnumStringEnum)]))); - } - if (object.directMap != null) { - result - ..add(r'direct_map') - ..add(serializers.serialize(object.directMap, - specifiedType: - const FullType(BuiltMap, [FullType(String), FullType(bool)]))); - } - if (object.indirectMap != null) { - result - ..add(r'indirect_map') - ..add(serializers.serialize(object.indirectMap, - specifiedType: - const FullType(BuiltMap, [FullType(String), FullType(bool)]))); - } - return result; - } - @override - MapTest deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = MapTestBuilder(); + @override + MapTest deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = MapTestBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'map_map_of_string': - result.mapMapOfString.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltMap, [FullType(String), FullType(String)]) - ])) as BuiltMap>); - break; - case r'map_of_enum_string': - result.mapOfEnumString.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltMap, [ - FullType(String), - FullType(MapTestMapOfEnumStringEnum) - ])) as BuiltMap); - break; - case r'direct_map': - result.directMap.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(bool)])) - as BuiltMap); - break; - case r'indirect_map': - result.indirectMap.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(bool)])) - as BuiltMap); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'map_map_of_string': + result.mapMapOfString.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltMap, [FullType(String), FullType(String)])])) as BuiltMap>); + break; + case r'map_of_enum_string': + result.mapOfEnumString.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(MapTestMapOfEnumStringEnum)])) as BuiltMap); + break; + case r'direct_map': + result.directMap.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])) as BuiltMap); + break; + case r'indirect_map': + result.indirectMap.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(bool)])) as BuiltMap); + break; + } + } + return result.build(); } - return result.build(); - } } class MapTestMapOfEnumStringEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'UPPER') - static const MapTestMapOfEnumStringEnum UPPER = - _$mapTestMapOfEnumStringEnum_UPPER; + static const MapTestMapOfEnumStringEnum UPPER = _$mapTestMapOfEnumStringEnum_UPPER; @BuiltValueEnumConst(wireName: r'lower') - static const MapTestMapOfEnumStringEnum lower = - _$mapTestMapOfEnumStringEnum_lower; + static const MapTestMapOfEnumStringEnum lower = _$mapTestMapOfEnumStringEnum_lower; - static Serializer get serializer => - _$mapTestMapOfEnumStringEnumSerializer; + static Serializer get serializer => _$mapTestMapOfEnumStringEnumSerializer; - const MapTestMapOfEnumStringEnum._(String name) : super(name); + const MapTestMapOfEnumStringEnum._(String name): super(name); - static BuiltSet get values => - _$mapTestMapOfEnumStringEnumValues; - static MapTestMapOfEnumStringEnum valueOf(String name) => - _$mapTestMapOfEnumStringEnumValueOf(name); + static BuiltSet get values => _$mapTestMapOfEnumStringEnumValues; + static MapTestMapOfEnumStringEnum valueOf(String name) => _$mapTestMapOfEnumStringEnumValueOf(name); } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart index 0e4c5b275cc..4da5f4d520d 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/mixed_properties_and_additional_properties_class.dart @@ -9,103 +9,86 @@ import 'package:built_value/serializer.dart'; part 'mixed_properties_and_additional_properties_class.g.dart'; -abstract class MixedPropertiesAndAdditionalPropertiesClass - implements - Built { - @BuiltValueField(wireName: r'uuid') - String? get uuid; - @BuiltValueField(wireName: r'dateTime') - DateTime? get dateTime; - @BuiltValueField(wireName: r'map') - BuiltMap? get map; +abstract class MixedPropertiesAndAdditionalPropertiesClass implements Built { + @BuiltValueField(wireName: r'uuid') + String? get uuid; - MixedPropertiesAndAdditionalPropertiesClass._(); + @BuiltValueField(wireName: r'dateTime') + DateTime? get dateTime; - static void _initializeBuilder( - MixedPropertiesAndAdditionalPropertiesClassBuilder b) => - b; + @BuiltValueField(wireName: r'map') + BuiltMap? get map; - factory MixedPropertiesAndAdditionalPropertiesClass( - [void updates( - MixedPropertiesAndAdditionalPropertiesClassBuilder b)]) = - _$MixedPropertiesAndAdditionalPropertiesClass; + MixedPropertiesAndAdditionalPropertiesClass._(); - @BuiltValueSerializer(custom: true) - static Serializer - get serializer => - _$MixedPropertiesAndAdditionalPropertiesClassSerializer(); + static void _initializeBuilder(MixedPropertiesAndAdditionalPropertiesClassBuilder b) => b; + + factory MixedPropertiesAndAdditionalPropertiesClass([void updates(MixedPropertiesAndAdditionalPropertiesClassBuilder b)]) = _$MixedPropertiesAndAdditionalPropertiesClass; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$MixedPropertiesAndAdditionalPropertiesClassSerializer(); } -class _$MixedPropertiesAndAdditionalPropertiesClassSerializer - implements - StructuredSerializer { - @override - final Iterable types = const [ - MixedPropertiesAndAdditionalPropertiesClass, - _$MixedPropertiesAndAdditionalPropertiesClass - ]; +class _$MixedPropertiesAndAdditionalPropertiesClassSerializer implements StructuredSerializer { + @override + final Iterable types = const [MixedPropertiesAndAdditionalPropertiesClass, _$MixedPropertiesAndAdditionalPropertiesClass]; - @override - final String wireName = r'MixedPropertiesAndAdditionalPropertiesClass'; + @override + final String wireName = r'MixedPropertiesAndAdditionalPropertiesClass'; - @override - Iterable serialize(Serializers serializers, - MixedPropertiesAndAdditionalPropertiesClass object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.uuid != null) { - result - ..add(r'uuid') - ..add(serializers.serialize(object.uuid, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, MixedPropertiesAndAdditionalPropertiesClass object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.uuid != null) { + result + ..add(r'uuid') + ..add(serializers.serialize(object.uuid, + specifiedType: const FullType(String))); + } + if (object.dateTime != null) { + result + ..add(r'dateTime') + ..add(serializers.serialize(object.dateTime, + specifiedType: const FullType(DateTime))); + } + if (object.map != null) { + result + ..add(r'map') + ..add(serializers.serialize(object.map, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)]))); + } + return result; } - if (object.dateTime != null) { - result - ..add(r'dateTime') - ..add(serializers.serialize(object.dateTime, - specifiedType: const FullType(DateTime))); - } - if (object.map != null) { - result - ..add(r'map') - ..add(serializers.serialize(object.map, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(Animal)]))); - } - return result; - } - @override - MixedPropertiesAndAdditionalPropertiesClass deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = MixedPropertiesAndAdditionalPropertiesClassBuilder(); + @override + MixedPropertiesAndAdditionalPropertiesClass deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = MixedPropertiesAndAdditionalPropertiesClassBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'uuid': - result.uuid = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'dateTime': - result.dateTime = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'map': - result.map.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(Animal)])) - as BuiltMap); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'uuid': + result.uuid = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'dateTime': + result.dateTime = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'map': + result.map.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Animal)])) as BuiltMap); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model200_response.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model200_response.dart index 457494bed53..be8614351cb 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model200_response.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model200_response.dart @@ -7,75 +7,73 @@ import 'package:built_value/serializer.dart'; part 'model200_response.g.dart'; -abstract class Model200Response - implements Built { - @BuiltValueField(wireName: r'name') - int? get name; - @BuiltValueField(wireName: r'class') - String? get class_; - Model200Response._(); +abstract class Model200Response implements Built { + @BuiltValueField(wireName: r'name') + int? get name; - static void _initializeBuilder(Model200ResponseBuilder b) => b; + @BuiltValueField(wireName: r'class') + String? get class_; - factory Model200Response([void updates(Model200ResponseBuilder b)]) = - _$Model200Response; + Model200Response._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$Model200ResponseSerializer(); + static void _initializeBuilder(Model200ResponseBuilder b) => b; + + factory Model200Response([void updates(Model200ResponseBuilder b)]) = _$Model200Response; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$Model200ResponseSerializer(); } -class _$Model200ResponseSerializer - implements StructuredSerializer { - @override - final Iterable types = const [Model200Response, _$Model200Response]; +class _$Model200ResponseSerializer implements StructuredSerializer { + @override + final Iterable types = const [Model200Response, _$Model200Response]; - @override - final String wireName = r'Model200Response'; + @override + final String wireName = r'Model200Response'; - @override - Iterable serialize(Serializers serializers, Model200Response object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.name != null) { - result - ..add(r'name') - ..add(serializers.serialize(object.name, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Model200Response object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.name != null) { + result + ..add(r'name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(int))); + } + if (object.class_ != null) { + result + ..add(r'class') + ..add(serializers.serialize(object.class_, + specifiedType: const FullType(String))); + } + return result; } - if (object.class_ != null) { - result - ..add(r'class') - ..add(serializers.serialize(object.class_, - specifiedType: const FullType(String))); - } - return result; - } - @override - Model200Response deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = Model200ResponseBuilder(); + @override + Model200Response deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = Model200ResponseBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'name': - result.name = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'class': - result.class_ = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'class': + result.class_ = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_client.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_client.dart index acbb28fc732..57871562a07 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_client.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_client.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'model_client.g.dart'; + + abstract class ModelClient implements Built { - @BuiltValueField(wireName: r'client') - String? get client; + @BuiltValueField(wireName: r'client') + String? get client; - ModelClient._(); + ModelClient._(); - static void _initializeBuilder(ModelClientBuilder b) => b; + static void _initializeBuilder(ModelClientBuilder b) => b; - factory ModelClient([void updates(ModelClientBuilder b)]) = _$ModelClient; + factory ModelClient([void updates(ModelClientBuilder b)]) = _$ModelClient; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ModelClientSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ModelClientSerializer(); } class _$ModelClientSerializer implements StructuredSerializer { - @override - final Iterable types = const [ModelClient, _$ModelClient]; + @override + final Iterable types = const [ModelClient, _$ModelClient]; - @override - final String wireName = r'ModelClient'; + @override + final String wireName = r'ModelClient'; - @override - Iterable serialize(Serializers serializers, ModelClient object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.client != null) { - result - ..add(r'client') - ..add(serializers.serialize(object.client, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, ModelClient object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.client != null) { + result + ..add(r'client') + ..add(serializers.serialize(object.client, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - ModelClient deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ModelClientBuilder(); + @override + ModelClient deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ModelClientBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'client': - result.client = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'client': + result.client = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_enum_class.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_enum_class.dart index 9ecc6e9fe8e..ba6ca8c45dd 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_enum_class.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_enum_class.dart @@ -9,18 +9,17 @@ import 'package:built_value/serializer.dart'; part 'model_enum_class.g.dart'; class ModelEnumClass extends EnumClass { + @BuiltValueEnumConst(wireName: r'_abc') static const ModelEnumClass abc = _$abc; @BuiltValueEnumConst(wireName: r'-efg') static const ModelEnumClass efg = _$efg; @BuiltValueEnumConst(wireName: r'(xyz)') - static const ModelEnumClass leftParenthesisXyzRightParenthesis = - _$leftParenthesisXyzRightParenthesis; + static const ModelEnumClass leftParenthesisXyzRightParenthesis = _$leftParenthesisXyzRightParenthesis; - static Serializer get serializer => - _$modelEnumClassSerializer; + static Serializer get serializer => _$modelEnumClassSerializer; - const ModelEnumClass._(String name) : super(name); + const ModelEnumClass._(String name): super(name); static BuiltSet get values => _$values; static ModelEnumClass valueOf(String name) => _$valueOf(name); @@ -33,3 +32,4 @@ class ModelEnumClass extends EnumClass { /// /// Trigger mixin generation by writing a line like this one next to your enum. abstract class ModelEnumClassMixin = Object with _$ModelEnumClassMixin; + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_file.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_file.dart index 1c5e4b86981..8a6c468bc00 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_file.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_file.dart @@ -7,58 +7,61 @@ import 'package:built_value/serializer.dart'; part 'model_file.g.dart'; + + abstract class ModelFile implements Built { - /// Test capitalization - @BuiltValueField(wireName: r'sourceURI') - String? get sourceURI; + /// Test capitalization + @BuiltValueField(wireName: r'sourceURI') + String? get sourceURI; - ModelFile._(); + ModelFile._(); - static void _initializeBuilder(ModelFileBuilder b) => b; + static void _initializeBuilder(ModelFileBuilder b) => b; - factory ModelFile([void updates(ModelFileBuilder b)]) = _$ModelFile; + factory ModelFile([void updates(ModelFileBuilder b)]) = _$ModelFile; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ModelFileSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ModelFileSerializer(); } class _$ModelFileSerializer implements StructuredSerializer { - @override - final Iterable types = const [ModelFile, _$ModelFile]; + @override + final Iterable types = const [ModelFile, _$ModelFile]; - @override - final String wireName = r'ModelFile'; + @override + final String wireName = r'ModelFile'; - @override - Iterable serialize(Serializers serializers, ModelFile object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.sourceURI != null) { - result - ..add(r'sourceURI') - ..add(serializers.serialize(object.sourceURI, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, ModelFile object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.sourceURI != null) { + result + ..add(r'sourceURI') + ..add(serializers.serialize(object.sourceURI, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - ModelFile deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ModelFileBuilder(); + @override + ModelFile deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ModelFileBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'sourceURI': - result.sourceURI = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'sourceURI': + result.sourceURI = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_list.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_list.dart index 53fe912acb1..901616e8dc6 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_list.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_list.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'model_list.g.dart'; + + abstract class ModelList implements Built { - @BuiltValueField(wireName: r'123-list') - String? get n123list; + @BuiltValueField(wireName: r'123-list') + String? get n123list; - ModelList._(); + ModelList._(); - static void _initializeBuilder(ModelListBuilder b) => b; + static void _initializeBuilder(ModelListBuilder b) => b; - factory ModelList([void updates(ModelListBuilder b)]) = _$ModelList; + factory ModelList([void updates(ModelListBuilder b)]) = _$ModelList; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ModelListSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ModelListSerializer(); } class _$ModelListSerializer implements StructuredSerializer { - @override - final Iterable types = const [ModelList, _$ModelList]; + @override + final Iterable types = const [ModelList, _$ModelList]; - @override - final String wireName = r'ModelList'; + @override + final String wireName = r'ModelList'; - @override - Iterable serialize(Serializers serializers, ModelList object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.n123list != null) { - result - ..add(r'123-list') - ..add(serializers.serialize(object.n123list, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, ModelList object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.n123list != null) { + result + ..add(r'123-list') + ..add(serializers.serialize(object.n123list, + specifiedType: const FullType(String))); + } + return result; } - return result; - } - @override - ModelList deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ModelListBuilder(); + @override + ModelList deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ModelListBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'123-list': - result.n123list = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'123-list': + result.n123list = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_return.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_return.dart index 9015504dc6e..42c03755627 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_return.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/model_return.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'model_return.g.dart'; + + abstract class ModelReturn implements Built { - @BuiltValueField(wireName: r'return') - int? get return_; + @BuiltValueField(wireName: r'return') + int? get return_; - ModelReturn._(); + ModelReturn._(); - static void _initializeBuilder(ModelReturnBuilder b) => b; + static void _initializeBuilder(ModelReturnBuilder b) => b; - factory ModelReturn([void updates(ModelReturnBuilder b)]) = _$ModelReturn; + factory ModelReturn([void updates(ModelReturnBuilder b)]) = _$ModelReturn; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ModelReturnSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ModelReturnSerializer(); } class _$ModelReturnSerializer implements StructuredSerializer { - @override - final Iterable types = const [ModelReturn, _$ModelReturn]; + @override + final Iterable types = const [ModelReturn, _$ModelReturn]; - @override - final String wireName = r'ModelReturn'; + @override + final String wireName = r'ModelReturn'; - @override - Iterable serialize(Serializers serializers, ModelReturn object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.return_ != null) { - result - ..add(r'return') - ..add(serializers.serialize(object.return_, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, ModelReturn object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.return_ != null) { + result + ..add(r'return') + ..add(serializers.serialize(object.return_, + specifiedType: const FullType(int))); + } + return result; } - return result; - } - @override - ModelReturn deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ModelReturnBuilder(); + @override + ModelReturn deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ModelReturnBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'return': - result.return_ = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'return': + result.return_ = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/name.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/name.dart index 21472493361..911fa0a5471 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/name.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/name.dart @@ -7,94 +7,97 @@ import 'package:built_value/serializer.dart'; part 'name.g.dart'; + + abstract class Name implements Built { - @BuiltValueField(wireName: r'name') - int get name; + @BuiltValueField(wireName: r'name') + int get name; - @BuiltValueField(wireName: r'snake_case') - int? get snakeCase; + @BuiltValueField(wireName: r'snake_case') + int? get snakeCase; - @BuiltValueField(wireName: r'property') - String? get property; + @BuiltValueField(wireName: r'property') + String? get property; - @BuiltValueField(wireName: r'123Number') - int? get n123number; + @BuiltValueField(wireName: r'123Number') + int? get n123number; - Name._(); + Name._(); - static void _initializeBuilder(NameBuilder b) => b; + static void _initializeBuilder(NameBuilder b) => b; - factory Name([void updates(NameBuilder b)]) = _$Name; + factory Name([void updates(NameBuilder b)]) = _$Name; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$NameSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$NameSerializer(); } class _$NameSerializer implements StructuredSerializer { - @override - final Iterable types = const [Name, _$Name]; + @override + final Iterable types = const [Name, _$Name]; - @override - final String wireName = r'Name'; + @override + final String wireName = r'Name'; - @override - Iterable serialize(Serializers serializers, Name object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - result - ..add(r'name') - ..add(serializers.serialize(object.name, - specifiedType: const FullType(int))); - if (object.snakeCase != null) { - result - ..add(r'snake_case') - ..add(serializers.serialize(object.snakeCase, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Name object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + result + ..add(r'name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(int))); + if (object.snakeCase != null) { + result + ..add(r'snake_case') + ..add(serializers.serialize(object.snakeCase, + specifiedType: const FullType(int))); + } + if (object.property != null) { + result + ..add(r'property') + ..add(serializers.serialize(object.property, + specifiedType: const FullType(String))); + } + if (object.n123number != null) { + result + ..add(r'123Number') + ..add(serializers.serialize(object.n123number, + specifiedType: const FullType(int))); + } + return result; } - if (object.property != null) { - result - ..add(r'property') - ..add(serializers.serialize(object.property, - specifiedType: const FullType(String))); - } - if (object.n123number != null) { - result - ..add(r'123Number') - ..add(serializers.serialize(object.n123number, - specifiedType: const FullType(int))); - } - return result; - } - @override - Name deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = NameBuilder(); + @override + Name deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = NameBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'name': - result.name = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'snake_case': - result.snakeCase = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'property': - result.property = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'123Number': - result.n123number = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'snake_case': + result.snakeCase = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'property': + result.property = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'123Number': + result.n123number = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/nullable_class.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/nullable_class.dart index e4ca5bfd189..d244f510681 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/nullable_class.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/nullable_class.dart @@ -9,221 +9,203 @@ import 'package:built_value/serializer.dart'; part 'nullable_class.g.dart'; -abstract class NullableClass - implements Built { - @BuiltValueField(wireName: r'integer_prop') - int? get integerProp; - @BuiltValueField(wireName: r'number_prop') - num? get numberProp; - @BuiltValueField(wireName: r'boolean_prop') - bool? get booleanProp; +abstract class NullableClass implements Built { + @BuiltValueField(wireName: r'integer_prop') + int? get integerProp; - @BuiltValueField(wireName: r'string_prop') - String? get stringProp; + @BuiltValueField(wireName: r'number_prop') + num? get numberProp; - @BuiltValueField(wireName: r'date_prop') - DateTime? get dateProp; + @BuiltValueField(wireName: r'boolean_prop') + bool? get booleanProp; - @BuiltValueField(wireName: r'datetime_prop') - DateTime? get datetimeProp; + @BuiltValueField(wireName: r'string_prop') + String? get stringProp; - @BuiltValueField(wireName: r'array_nullable_prop') - BuiltList? get arrayNullableProp; + @BuiltValueField(wireName: r'date_prop') + DateTime? get dateProp; - @BuiltValueField(wireName: r'array_and_items_nullable_prop') - BuiltList? get arrayAndItemsNullableProp; + @BuiltValueField(wireName: r'datetime_prop') + DateTime? get datetimeProp; - @BuiltValueField(wireName: r'array_items_nullable') - BuiltList? get arrayItemsNullable; + @BuiltValueField(wireName: r'array_nullable_prop') + BuiltList? get arrayNullableProp; - @BuiltValueField(wireName: r'object_nullable_prop') - BuiltMap? get objectNullableProp; + @BuiltValueField(wireName: r'array_and_items_nullable_prop') + BuiltList? get arrayAndItemsNullableProp; - @BuiltValueField(wireName: r'object_and_items_nullable_prop') - BuiltMap? get objectAndItemsNullableProp; + @BuiltValueField(wireName: r'array_items_nullable') + BuiltList? get arrayItemsNullable; - @BuiltValueField(wireName: r'object_items_nullable') - BuiltMap? get objectItemsNullable; + @BuiltValueField(wireName: r'object_nullable_prop') + BuiltMap? get objectNullableProp; - NullableClass._(); + @BuiltValueField(wireName: r'object_and_items_nullable_prop') + BuiltMap? get objectAndItemsNullableProp; - static void _initializeBuilder(NullableClassBuilder b) => b; + @BuiltValueField(wireName: r'object_items_nullable') + BuiltMap? get objectItemsNullable; - factory NullableClass([void updates(NullableClassBuilder b)]) = - _$NullableClass; + NullableClass._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$NullableClassSerializer(); + static void _initializeBuilder(NullableClassBuilder b) => b; + + factory NullableClass([void updates(NullableClassBuilder b)]) = _$NullableClass; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$NullableClassSerializer(); } class _$NullableClassSerializer implements StructuredSerializer { - @override - final Iterable types = const [NullableClass, _$NullableClass]; + @override + final Iterable types = const [NullableClass, _$NullableClass]; - @override - final String wireName = r'NullableClass'; + @override + final String wireName = r'NullableClass'; - @override - Iterable serialize(Serializers serializers, NullableClass object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.integerProp != null) { - result - ..add(r'integer_prop') - ..add(serializers.serialize(object.integerProp, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, NullableClass object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.integerProp != null) { + result + ..add(r'integer_prop') + ..add(serializers.serialize(object.integerProp, + specifiedType: const FullType(int))); + } + if (object.numberProp != null) { + result + ..add(r'number_prop') + ..add(serializers.serialize(object.numberProp, + specifiedType: const FullType(num))); + } + if (object.booleanProp != null) { + result + ..add(r'boolean_prop') + ..add(serializers.serialize(object.booleanProp, + specifiedType: const FullType(bool))); + } + if (object.stringProp != null) { + result + ..add(r'string_prop') + ..add(serializers.serialize(object.stringProp, + specifiedType: const FullType(String))); + } + if (object.dateProp != null) { + result + ..add(r'date_prop') + ..add(serializers.serialize(object.dateProp, + specifiedType: const FullType(DateTime))); + } + if (object.datetimeProp != null) { + result + ..add(r'datetime_prop') + ..add(serializers.serialize(object.datetimeProp, + specifiedType: const FullType(DateTime))); + } + if (object.arrayNullableProp != null) { + result + ..add(r'array_nullable_prop') + ..add(serializers.serialize(object.arrayNullableProp, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + if (object.arrayAndItemsNullableProp != null) { + result + ..add(r'array_and_items_nullable_prop') + ..add(serializers.serialize(object.arrayAndItemsNullableProp, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + if (object.arrayItemsNullable != null) { + result + ..add(r'array_items_nullable') + ..add(serializers.serialize(object.arrayItemsNullable, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + if (object.objectNullableProp != null) { + result + ..add(r'object_nullable_prop') + ..add(serializers.serialize(object.objectNullableProp, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)]))); + } + if (object.objectAndItemsNullableProp != null) { + result + ..add(r'object_and_items_nullable_prop') + ..add(serializers.serialize(object.objectAndItemsNullableProp, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)]))); + } + if (object.objectItemsNullable != null) { + result + ..add(r'object_items_nullable') + ..add(serializers.serialize(object.objectItemsNullable, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)]))); + } + return result; } - if (object.numberProp != null) { - result - ..add(r'number_prop') - ..add(serializers.serialize(object.numberProp, - specifiedType: const FullType(num))); - } - if (object.booleanProp != null) { - result - ..add(r'boolean_prop') - ..add(serializers.serialize(object.booleanProp, - specifiedType: const FullType(bool))); - } - if (object.stringProp != null) { - result - ..add(r'string_prop') - ..add(serializers.serialize(object.stringProp, - specifiedType: const FullType(String))); - } - if (object.dateProp != null) { - result - ..add(r'date_prop') - ..add(serializers.serialize(object.dateProp, - specifiedType: const FullType(DateTime))); - } - if (object.datetimeProp != null) { - result - ..add(r'datetime_prop') - ..add(serializers.serialize(object.datetimeProp, - specifiedType: const FullType(DateTime))); - } - if (object.arrayNullableProp != null) { - result - ..add(r'array_nullable_prop') - ..add(serializers.serialize(object.arrayNullableProp, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); - } - if (object.arrayAndItemsNullableProp != null) { - result - ..add(r'array_and_items_nullable_prop') - ..add(serializers.serialize(object.arrayAndItemsNullableProp, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); - } - if (object.arrayItemsNullable != null) { - result - ..add(r'array_items_nullable') - ..add(serializers.serialize(object.arrayItemsNullable, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); - } - if (object.objectNullableProp != null) { - result - ..add(r'object_nullable_prop') - ..add(serializers.serialize(object.objectNullableProp, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)]))); - } - if (object.objectAndItemsNullableProp != null) { - result - ..add(r'object_and_items_nullable_prop') - ..add(serializers.serialize(object.objectAndItemsNullableProp, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)]))); - } - if (object.objectItemsNullable != null) { - result - ..add(r'object_items_nullable') - ..add(serializers.serialize(object.objectItemsNullable, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)]))); - } - return result; - } - @override - NullableClass deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = NullableClassBuilder(); + @override + NullableClass deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = NullableClassBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'integer_prop': - result.integerProp = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'number_prop': - result.numberProp = serializers.deserialize(value, - specifiedType: const FullType(num)) as num; - break; - case r'boolean_prop': - result.booleanProp = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; - case r'string_prop': - result.stringProp = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'date_prop': - result.dateProp = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'datetime_prop': - result.datetimeProp = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'array_nullable_prop': - result.arrayNullableProp.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, [FullType(JsonObject)])) - as BuiltList); - break; - case r'array_and_items_nullable_prop': - result.arrayAndItemsNullableProp.replace(serializers.deserialize( - value, - specifiedType: - const FullType(BuiltList, [FullType(JsonObject)])) - as BuiltList); - break; - case r'array_items_nullable': - result.arrayItemsNullable.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, [FullType(JsonObject)])) - as BuiltList); - break; - case r'object_nullable_prop': - result.objectNullableProp.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)])) - as BuiltMap); - break; - case r'object_and_items_nullable_prop': - result.objectAndItemsNullableProp.replace(serializers.deserialize( - value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)])) - as BuiltMap); - break; - case r'object_items_nullable': - result.objectItemsNullable.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltMap, [FullType(String), FullType(JsonObject)])) - as BuiltMap); - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'integer_prop': + result.integerProp = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'number_prop': + result.numberProp = serializers.deserialize(value, + specifiedType: const FullType(num)) as num; + break; + case r'boolean_prop': + result.booleanProp = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; + case r'string_prop': + result.stringProp = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'date_prop': + result.dateProp = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'datetime_prop': + result.datetimeProp = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'array_nullable_prop': + result.arrayNullableProp.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)])) as BuiltList); + break; + case r'array_and_items_nullable_prop': + result.arrayAndItemsNullableProp.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)])) as BuiltList); + break; + case r'array_items_nullable': + result.arrayItemsNullable.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)])) as BuiltList); + break; + case r'object_nullable_prop': + result.objectNullableProp.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)])) as BuiltMap); + break; + case r'object_and_items_nullable_prop': + result.objectAndItemsNullableProp.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)])) as BuiltMap); + break; + case r'object_items_nullable': + result.objectItemsNullable.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonObject)])) as BuiltMap); + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/number_only.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/number_only.dart index 3e4cde2b406..55e00d4d65c 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/number_only.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/number_only.dart @@ -7,57 +7,60 @@ import 'package:built_value/serializer.dart'; part 'number_only.g.dart'; + + abstract class NumberOnly implements Built { - @BuiltValueField(wireName: r'JustNumber') - num? get justNumber; + @BuiltValueField(wireName: r'JustNumber') + num? get justNumber; - NumberOnly._(); + NumberOnly._(); - static void _initializeBuilder(NumberOnlyBuilder b) => b; + static void _initializeBuilder(NumberOnlyBuilder b) => b; - factory NumberOnly([void updates(NumberOnlyBuilder b)]) = _$NumberOnly; + factory NumberOnly([void updates(NumberOnlyBuilder b)]) = _$NumberOnly; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$NumberOnlySerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$NumberOnlySerializer(); } class _$NumberOnlySerializer implements StructuredSerializer { - @override - final Iterable types = const [NumberOnly, _$NumberOnly]; + @override + final Iterable types = const [NumberOnly, _$NumberOnly]; - @override - final String wireName = r'NumberOnly'; + @override + final String wireName = r'NumberOnly'; - @override - Iterable serialize(Serializers serializers, NumberOnly object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.justNumber != null) { - result - ..add(r'JustNumber') - ..add(serializers.serialize(object.justNumber, - specifiedType: const FullType(num))); + @override + Iterable serialize(Serializers serializers, NumberOnly object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.justNumber != null) { + result + ..add(r'JustNumber') + ..add(serializers.serialize(object.justNumber, + specifiedType: const FullType(num))); + } + return result; } - return result; - } - @override - NumberOnly deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = NumberOnlyBuilder(); + @override + NumberOnly deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = NumberOnlyBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'JustNumber': - result.justNumber = serializers.deserialize(value, - specifiedType: const FullType(num)) as num; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'JustNumber': + result.justNumber = serializers.deserialize(value, + specifiedType: const FullType(num)) as num; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/order.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/order.dart index 15c416e5934..9c65fbf0c3a 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/order.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/order.dart @@ -8,147 +8,148 @@ import 'package:built_value/serializer.dart'; part 'order.g.dart'; + + abstract class Order implements Built { - @BuiltValueField(wireName: r'id') - int? get id; + @BuiltValueField(wireName: r'id') + int? get id; - @BuiltValueField(wireName: r'petId') - int? get petId; + @BuiltValueField(wireName: r'petId') + int? get petId; - @BuiltValueField(wireName: r'quantity') - int? get quantity; + @BuiltValueField(wireName: r'quantity') + int? get quantity; - @BuiltValueField(wireName: r'shipDate') - DateTime? get shipDate; + @BuiltValueField(wireName: r'shipDate') + DateTime? get shipDate; - /// Order Status - @BuiltValueField(wireName: r'status') - OrderStatusEnum? get status; - // enum statusEnum { placed, approved, delivered, }; + /// Order Status + @BuiltValueField(wireName: r'status') + OrderStatusEnum? get status; + // enum statusEnum { placed, approved, delivered, }; - @BuiltValueField(wireName: r'complete') - bool? get complete; + @BuiltValueField(wireName: r'complete') + bool? get complete; - Order._(); + Order._(); - static void _initializeBuilder(OrderBuilder b) => b..complete = false; + static void _initializeBuilder(OrderBuilder b) => b + ..complete = false; - factory Order([void updates(OrderBuilder b)]) = _$Order; + factory Order([void updates(OrderBuilder b)]) = _$Order; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$OrderSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OrderSerializer(); } class _$OrderSerializer implements StructuredSerializer { - @override - final Iterable types = const [Order, _$Order]; + @override + final Iterable types = const [Order, _$Order]; - @override - final String wireName = r'Order'; + @override + final String wireName = r'Order'; - @override - Iterable serialize(Serializers serializers, Order object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.id != null) { - result - ..add(r'id') - ..add(serializers.serialize(object.id, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Order object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.id != null) { + result + ..add(r'id') + ..add(serializers.serialize(object.id, + specifiedType: const FullType(int))); + } + if (object.petId != null) { + result + ..add(r'petId') + ..add(serializers.serialize(object.petId, + specifiedType: const FullType(int))); + } + if (object.quantity != null) { + result + ..add(r'quantity') + ..add(serializers.serialize(object.quantity, + specifiedType: const FullType(int))); + } + if (object.shipDate != null) { + result + ..add(r'shipDate') + ..add(serializers.serialize(object.shipDate, + specifiedType: const FullType(DateTime))); + } + if (object.status != null) { + result + ..add(r'status') + ..add(serializers.serialize(object.status, + specifiedType: const FullType(OrderStatusEnum))); + } + if (object.complete != null) { + result + ..add(r'complete') + ..add(serializers.serialize(object.complete, + specifiedType: const FullType(bool))); + } + return result; } - if (object.petId != null) { - result - ..add(r'petId') - ..add(serializers.serialize(object.petId, - specifiedType: const FullType(int))); - } - if (object.quantity != null) { - result - ..add(r'quantity') - ..add(serializers.serialize(object.quantity, - specifiedType: const FullType(int))); - } - if (object.shipDate != null) { - result - ..add(r'shipDate') - ..add(serializers.serialize(object.shipDate, - specifiedType: const FullType(DateTime))); - } - if (object.status != null) { - result - ..add(r'status') - ..add(serializers.serialize(object.status, - specifiedType: const FullType(OrderStatusEnum))); - } - if (object.complete != null) { - result - ..add(r'complete') - ..add(serializers.serialize(object.complete, - specifiedType: const FullType(bool))); - } - return result; - } - @override - Order deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = OrderBuilder(); + @override + Order deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OrderBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'petId': - result.petId = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'quantity': - result.quantity = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'shipDate': - result.shipDate = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - break; - case r'status': - result.status = serializers.deserialize(value, - specifiedType: const FullType(OrderStatusEnum)) - as OrderStatusEnum; - break; - case r'complete': - result.complete = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'petId': + result.petId = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'quantity': + result.quantity = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'shipDate': + result.shipDate = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + break; + case r'status': + result.status = serializers.deserialize(value, + specifiedType: const FullType(OrderStatusEnum)) as OrderStatusEnum; + break; + case r'complete': + result.complete = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; + } + } + return result.build(); } - return result.build(); - } } class OrderStatusEnum extends EnumClass { + /// Order Status @BuiltValueEnumConst(wireName: r'placed') static const OrderStatusEnum placed = _$orderStatusEnum_placed; - /// Order Status @BuiltValueEnumConst(wireName: r'approved') static const OrderStatusEnum approved = _$orderStatusEnum_approved; - /// Order Status @BuiltValueEnumConst(wireName: r'delivered') static const OrderStatusEnum delivered = _$orderStatusEnum_delivered; - static Serializer get serializer => - _$orderStatusEnumSerializer; + static Serializer get serializer => _$orderStatusEnumSerializer; - const OrderStatusEnum._(String name) : super(name); + const OrderStatusEnum._(String name): super(name); static BuiltSet get values => _$orderStatusEnumValues; static OrderStatusEnum valueOf(String name) => _$orderStatusEnumValueOf(name); } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_composite.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_composite.dart index fe16ebdaa5b..69007a11464 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_composite.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_composite.dart @@ -7,88 +7,86 @@ import 'package:built_value/serializer.dart'; part 'outer_composite.g.dart'; -abstract class OuterComposite - implements Built { - @BuiltValueField(wireName: r'my_number') - num? get myNumber; - @BuiltValueField(wireName: r'my_string') - String? get myString; - @BuiltValueField(wireName: r'my_boolean') - bool? get myBoolean; +abstract class OuterComposite implements Built { + @BuiltValueField(wireName: r'my_number') + num? get myNumber; - OuterComposite._(); + @BuiltValueField(wireName: r'my_string') + String? get myString; - static void _initializeBuilder(OuterCompositeBuilder b) => b; + @BuiltValueField(wireName: r'my_boolean') + bool? get myBoolean; - factory OuterComposite([void updates(OuterCompositeBuilder b)]) = - _$OuterComposite; + OuterComposite._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$OuterCompositeSerializer(); + static void _initializeBuilder(OuterCompositeBuilder b) => b; + + factory OuterComposite([void updates(OuterCompositeBuilder b)]) = _$OuterComposite; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OuterCompositeSerializer(); } -class _$OuterCompositeSerializer - implements StructuredSerializer { - @override - final Iterable types = const [OuterComposite, _$OuterComposite]; +class _$OuterCompositeSerializer implements StructuredSerializer { + @override + final Iterable types = const [OuterComposite, _$OuterComposite]; - @override - final String wireName = r'OuterComposite'; + @override + final String wireName = r'OuterComposite'; - @override - Iterable serialize(Serializers serializers, OuterComposite object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.myNumber != null) { - result - ..add(r'my_number') - ..add(serializers.serialize(object.myNumber, - specifiedType: const FullType(num))); + @override + Iterable serialize(Serializers serializers, OuterComposite object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.myNumber != null) { + result + ..add(r'my_number') + ..add(serializers.serialize(object.myNumber, + specifiedType: const FullType(num))); + } + if (object.myString != null) { + result + ..add(r'my_string') + ..add(serializers.serialize(object.myString, + specifiedType: const FullType(String))); + } + if (object.myBoolean != null) { + result + ..add(r'my_boolean') + ..add(serializers.serialize(object.myBoolean, + specifiedType: const FullType(bool))); + } + return result; } - if (object.myString != null) { - result - ..add(r'my_string') - ..add(serializers.serialize(object.myString, - specifiedType: const FullType(String))); - } - if (object.myBoolean != null) { - result - ..add(r'my_boolean') - ..add(serializers.serialize(object.myBoolean, - specifiedType: const FullType(bool))); - } - return result; - } - @override - OuterComposite deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = OuterCompositeBuilder(); + @override + OuterComposite deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OuterCompositeBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'my_number': - result.myNumber = serializers.deserialize(value, - specifiedType: const FullType(num)) as num; - break; - case r'my_string': - result.myString = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'my_boolean': - result.myBoolean = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'my_number': + result.myNumber = serializers.deserialize(value, + specifiedType: const FullType(num)) as num; + break; + case r'my_string': + result.myString = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'my_boolean': + result.myBoolean = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum.dart index 24423cf8927..6476ca57d46 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum.dart @@ -9,6 +9,7 @@ import 'package:built_value/serializer.dart'; part 'outer_enum.g.dart'; class OuterEnum extends EnumClass { + @BuiltValueEnumConst(wireName: r'placed') static const OuterEnum placed = _$placed; @BuiltValueEnumConst(wireName: r'approved') @@ -18,7 +19,7 @@ class OuterEnum extends EnumClass { static Serializer get serializer => _$outerEnumSerializer; - const OuterEnum._(String name) : super(name); + const OuterEnum._(String name): super(name); static BuiltSet get values => _$values; static OuterEnum valueOf(String name) => _$valueOf(name); @@ -31,3 +32,4 @@ class OuterEnum extends EnumClass { /// /// Trigger mixin generation by writing a line like this one next to your enum. abstract class OuterEnumMixin = Object with _$OuterEnumMixin; + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart index 8eef49b8f75..af04c76ed44 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_default_value.dart @@ -9,6 +9,7 @@ import 'package:built_value/serializer.dart'; part 'outer_enum_default_value.g.dart'; class OuterEnumDefaultValue extends EnumClass { + @BuiltValueEnumConst(wireName: r'placed') static const OuterEnumDefaultValue placed = _$placed; @BuiltValueEnumConst(wireName: r'approved') @@ -16,10 +17,9 @@ class OuterEnumDefaultValue extends EnumClass { @BuiltValueEnumConst(wireName: r'delivered') static const OuterEnumDefaultValue delivered = _$delivered; - static Serializer get serializer => - _$outerEnumDefaultValueSerializer; + static Serializer get serializer => _$outerEnumDefaultValueSerializer; - const OuterEnumDefaultValue._(String name) : super(name); + const OuterEnumDefaultValue._(String name): super(name); static BuiltSet get values => _$values; static OuterEnumDefaultValue valueOf(String name) => _$valueOf(name); @@ -31,5 +31,5 @@ class OuterEnumDefaultValue extends EnumClass { /// corresponding Angular template. /// /// Trigger mixin generation by writing a line like this one next to your enum. -abstract class OuterEnumDefaultValueMixin = Object - with _$OuterEnumDefaultValueMixin; +abstract class OuterEnumDefaultValueMixin = Object with _$OuterEnumDefaultValueMixin; + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart index 0a84bdbe790..c3b4b7d8f5d 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer.dart @@ -9,6 +9,7 @@ import 'package:built_value/serializer.dart'; part 'outer_enum_integer.g.dart'; class OuterEnumInteger extends EnumClass { + @BuiltValueEnumConst(wireNumber: 0) static const OuterEnumInteger number0 = _$number0; @BuiltValueEnumConst(wireNumber: 1) @@ -16,10 +17,9 @@ class OuterEnumInteger extends EnumClass { @BuiltValueEnumConst(wireNumber: 2) static const OuterEnumInteger number2 = _$number2; - static Serializer get serializer => - _$outerEnumIntegerSerializer; + static Serializer get serializer => _$outerEnumIntegerSerializer; - const OuterEnumInteger._(String name) : super(name); + const OuterEnumInteger._(String name): super(name); static BuiltSet get values => _$values; static OuterEnumInteger valueOf(String name) => _$valueOf(name); @@ -32,3 +32,4 @@ class OuterEnumInteger extends EnumClass { /// /// Trigger mixin generation by writing a line like this one next to your enum. abstract class OuterEnumIntegerMixin = Object with _$OuterEnumIntegerMixin; + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart index f926f5580c5..cf71a021765 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_enum_integer_default_value.dart @@ -9,6 +9,7 @@ import 'package:built_value/serializer.dart'; part 'outer_enum_integer_default_value.g.dart'; class OuterEnumIntegerDefaultValue extends EnumClass { + @BuiltValueEnumConst(wireNumber: 0) static const OuterEnumIntegerDefaultValue number0 = _$number0; @BuiltValueEnumConst(wireNumber: 1) @@ -16,10 +17,9 @@ class OuterEnumIntegerDefaultValue extends EnumClass { @BuiltValueEnumConst(wireNumber: 2) static const OuterEnumIntegerDefaultValue number2 = _$number2; - static Serializer get serializer => - _$outerEnumIntegerDefaultValueSerializer; + static Serializer get serializer => _$outerEnumIntegerDefaultValueSerializer; - const OuterEnumIntegerDefaultValue._(String name) : super(name); + const OuterEnumIntegerDefaultValue._(String name): super(name); static BuiltSet get values => _$values; static OuterEnumIntegerDefaultValue valueOf(String name) => _$valueOf(name); @@ -31,5 +31,5 @@ class OuterEnumIntegerDefaultValue extends EnumClass { /// corresponding Angular template. /// /// Trigger mixin generation by writing a line like this one next to your enum. -abstract class OuterEnumIntegerDefaultValueMixin = Object - with _$OuterEnumIntegerDefaultValueMixin; +abstract class OuterEnumIntegerDefaultValueMixin = Object with _$OuterEnumIntegerDefaultValueMixin; + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart index 5e76bfa112e..6f4563d7a5e 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/outer_object_with_enum_property.dart @@ -8,68 +8,59 @@ import 'package:built_value/serializer.dart'; part 'outer_object_with_enum_property.g.dart'; -abstract class OuterObjectWithEnumProperty - implements - Built { - @BuiltValueField(wireName: r'value') - OuterEnumInteger get value; - // enum valueEnum { 0, 1, 2, }; - OuterObjectWithEnumProperty._(); - static void _initializeBuilder(OuterObjectWithEnumPropertyBuilder b) => b; +abstract class OuterObjectWithEnumProperty implements Built { + @BuiltValueField(wireName: r'value') + OuterEnumInteger get value; + // enum valueEnum { 0, 1, 2, }; - factory OuterObjectWithEnumProperty( - [void updates(OuterObjectWithEnumPropertyBuilder b)]) = - _$OuterObjectWithEnumProperty; + OuterObjectWithEnumProperty._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$OuterObjectWithEnumPropertySerializer(); + static void _initializeBuilder(OuterObjectWithEnumPropertyBuilder b) => b; + + factory OuterObjectWithEnumProperty([void updates(OuterObjectWithEnumPropertyBuilder b)]) = _$OuterObjectWithEnumProperty; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OuterObjectWithEnumPropertySerializer(); } -class _$OuterObjectWithEnumPropertySerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - OuterObjectWithEnumProperty, - _$OuterObjectWithEnumProperty - ]; +class _$OuterObjectWithEnumPropertySerializer implements StructuredSerializer { + @override + final Iterable types = const [OuterObjectWithEnumProperty, _$OuterObjectWithEnumProperty]; - @override - final String wireName = r'OuterObjectWithEnumProperty'; + @override + final String wireName = r'OuterObjectWithEnumProperty'; - @override - Iterable serialize( - Serializers serializers, OuterObjectWithEnumProperty object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - result - ..add(r'value') - ..add(serializers.serialize(object.value, - specifiedType: const FullType(OuterEnumInteger))); - return result; - } - - @override - OuterObjectWithEnumProperty deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = OuterObjectWithEnumPropertyBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'value': - result.value = serializers.deserialize(value, - specifiedType: const FullType(OuterEnumInteger)) - as OuterEnumInteger; - break; - } + @override + Iterable serialize(Serializers serializers, OuterObjectWithEnumProperty object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + result + ..add(r'value') + ..add(serializers.serialize(object.value, + specifiedType: const FullType(OuterEnumInteger))); + return result; + } + + @override + OuterObjectWithEnumProperty deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OuterObjectWithEnumPropertyBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'value': + result.value = serializers.deserialize(value, + specifiedType: const FullType(OuterEnumInteger)) as OuterEnumInteger; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/pet.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/pet.dart index 1161b1d37e0..99ef939eb1b 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/pet.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/pet.dart @@ -10,143 +10,143 @@ import 'package:built_value/serializer.dart'; part 'pet.g.dart'; + + abstract class Pet implements Built { - @BuiltValueField(wireName: r'id') - int? get id; + @BuiltValueField(wireName: r'id') + int? get id; - @BuiltValueField(wireName: r'category') - Category? get category; + @BuiltValueField(wireName: r'category') + Category? get category; - @BuiltValueField(wireName: r'name') - String get name; + @BuiltValueField(wireName: r'name') + String get name; - @BuiltValueField(wireName: r'photoUrls') - BuiltSet get photoUrls; + @BuiltValueField(wireName: r'photoUrls') + BuiltSet get photoUrls; - @BuiltValueField(wireName: r'tags') - BuiltList? get tags; + @BuiltValueField(wireName: r'tags') + BuiltList? get tags; - /// pet status in the store - @BuiltValueField(wireName: r'status') - PetStatusEnum? get status; - // enum statusEnum { available, pending, sold, }; + /// pet status in the store + @BuiltValueField(wireName: r'status') + PetStatusEnum? get status; + // enum statusEnum { available, pending, sold, }; - Pet._(); + Pet._(); - static void _initializeBuilder(PetBuilder b) => b; + static void _initializeBuilder(PetBuilder b) => b; - factory Pet([void updates(PetBuilder b)]) = _$Pet; + factory Pet([void updates(PetBuilder b)]) = _$Pet; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$PetSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$PetSerializer(); } class _$PetSerializer implements StructuredSerializer { - @override - final Iterable types = const [Pet, _$Pet]; + @override + final Iterable types = const [Pet, _$Pet]; - @override - final String wireName = r'Pet'; + @override + final String wireName = r'Pet'; - @override - Iterable serialize(Serializers serializers, Pet object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.id != null) { - result - ..add(r'id') - ..add(serializers.serialize(object.id, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Pet object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.id != null) { + result + ..add(r'id') + ..add(serializers.serialize(object.id, + specifiedType: const FullType(int))); + } + if (object.category != null) { + result + ..add(r'category') + ..add(serializers.serialize(object.category, + specifiedType: const FullType(Category))); + } + result + ..add(r'name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(String))); + result + ..add(r'photoUrls') + ..add(serializers.serialize(object.photoUrls, + specifiedType: const FullType(BuiltSet, [FullType(String)]))); + if (object.tags != null) { + result + ..add(r'tags') + ..add(serializers.serialize(object.tags, + specifiedType: const FullType(BuiltList, [FullType(Tag)]))); + } + if (object.status != null) { + result + ..add(r'status') + ..add(serializers.serialize(object.status, + specifiedType: const FullType(PetStatusEnum))); + } + return result; } - if (object.category != null) { - result - ..add(r'category') - ..add(serializers.serialize(object.category, - specifiedType: const FullType(Category))); - } - result - ..add(r'name') - ..add(serializers.serialize(object.name, - specifiedType: const FullType(String))); - result - ..add(r'photoUrls') - ..add(serializers.serialize(object.photoUrls, - specifiedType: const FullType(BuiltSet, [FullType(String)]))); - if (object.tags != null) { - result - ..add(r'tags') - ..add(serializers.serialize(object.tags, - specifiedType: const FullType(BuiltList, [FullType(Tag)]))); - } - if (object.status != null) { - result - ..add(r'status') - ..add(serializers.serialize(object.status, - specifiedType: const FullType(PetStatusEnum))); - } - return result; - } - @override - Pet deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = PetBuilder(); + @override + Pet deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = PetBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'category': - result.category.replace(serializers.deserialize(value, - specifiedType: const FullType(Category)) as Category); - break; - case r'name': - result.name = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'photoUrls': - result.photoUrls.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltSet, [FullType(String)])) - as BuiltSet); - break; - case r'tags': - result.tags.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(Tag)])) - as BuiltList); - break; - case r'status': - result.status = serializers.deserialize(value, - specifiedType: const FullType(PetStatusEnum)) as PetStatusEnum; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'category': + result.category.replace(serializers.deserialize(value, + specifiedType: const FullType(Category)) as Category); + break; + case r'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'photoUrls': + result.photoUrls.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltSet, [FullType(String)])) as BuiltSet); + break; + case r'tags': + result.tags.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(Tag)])) as BuiltList); + break; + case r'status': + result.status = serializers.deserialize(value, + specifiedType: const FullType(PetStatusEnum)) as PetStatusEnum; + break; + } + } + return result.build(); } - return result.build(); - } } class PetStatusEnum extends EnumClass { + /// pet status in the store @BuiltValueEnumConst(wireName: r'available') static const PetStatusEnum available = _$petStatusEnum_available; - /// pet status in the store @BuiltValueEnumConst(wireName: r'pending') static const PetStatusEnum pending = _$petStatusEnum_pending; - /// pet status in the store @BuiltValueEnumConst(wireName: r'sold') static const PetStatusEnum sold = _$petStatusEnum_sold; static Serializer get serializer => _$petStatusEnumSerializer; - const PetStatusEnum._(String name) : super(name); + const PetStatusEnum._(String name): super(name); static BuiltSet get values => _$petStatusEnumValues; static PetStatusEnum valueOf(String name) => _$petStatusEnumValueOf(name); } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/read_only_first.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/read_only_first.dart index 99b152f04cc..d53617d1c0b 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/read_only_first.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/read_only_first.dart @@ -7,74 +7,73 @@ import 'package:built_value/serializer.dart'; part 'read_only_first.g.dart'; -abstract class ReadOnlyFirst - implements Built { - @BuiltValueField(wireName: r'bar') - String? get bar; - @BuiltValueField(wireName: r'baz') - String? get baz; - ReadOnlyFirst._(); +abstract class ReadOnlyFirst implements Built { + @BuiltValueField(wireName: r'bar') + String? get bar; - static void _initializeBuilder(ReadOnlyFirstBuilder b) => b; + @BuiltValueField(wireName: r'baz') + String? get baz; - factory ReadOnlyFirst([void updates(ReadOnlyFirstBuilder b)]) = - _$ReadOnlyFirst; + ReadOnlyFirst._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$ReadOnlyFirstSerializer(); + static void _initializeBuilder(ReadOnlyFirstBuilder b) => b; + + factory ReadOnlyFirst([void updates(ReadOnlyFirstBuilder b)]) = _$ReadOnlyFirst; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ReadOnlyFirstSerializer(); } class _$ReadOnlyFirstSerializer implements StructuredSerializer { - @override - final Iterable types = const [ReadOnlyFirst, _$ReadOnlyFirst]; + @override + final Iterable types = const [ReadOnlyFirst, _$ReadOnlyFirst]; - @override - final String wireName = r'ReadOnlyFirst'; + @override + final String wireName = r'ReadOnlyFirst'; - @override - Iterable serialize(Serializers serializers, ReadOnlyFirst object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.bar != null) { - result - ..add(r'bar') - ..add(serializers.serialize(object.bar, - specifiedType: const FullType(String))); + @override + Iterable serialize(Serializers serializers, ReadOnlyFirst object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.bar != null) { + result + ..add(r'bar') + ..add(serializers.serialize(object.bar, + specifiedType: const FullType(String))); + } + if (object.baz != null) { + result + ..add(r'baz') + ..add(serializers.serialize(object.baz, + specifiedType: const FullType(String))); + } + return result; } - if (object.baz != null) { - result - ..add(r'baz') - ..add(serializers.serialize(object.baz, - specifiedType: const FullType(String))); - } - return result; - } - @override - ReadOnlyFirst deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = ReadOnlyFirstBuilder(); + @override + ReadOnlyFirst deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ReadOnlyFirstBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'bar': - result.bar = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'baz': - result.baz = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'bar': + result.bar = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'baz': + result.baz = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/special_model_name.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/special_model_name.dart index f1db8a22051..36880f32998 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/special_model_name.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/special_model_name.dart @@ -7,67 +7,60 @@ import 'package:built_value/serializer.dart'; part 'special_model_name.g.dart'; -abstract class SpecialModelName - implements Built { - @BuiltValueField(wireName: r'$special[property.name]') - int? get dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket; - SpecialModelName._(); - static void _initializeBuilder(SpecialModelNameBuilder b) => b; +abstract class SpecialModelName implements Built { + @BuiltValueField(wireName: r'$special[property.name]') + int? get dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket; - factory SpecialModelName([void updates(SpecialModelNameBuilder b)]) = - _$SpecialModelName; + SpecialModelName._(); - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$SpecialModelNameSerializer(); + static void _initializeBuilder(SpecialModelNameBuilder b) => b; + + factory SpecialModelName([void updates(SpecialModelNameBuilder b)]) = _$SpecialModelName; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$SpecialModelNameSerializer(); } -class _$SpecialModelNameSerializer - implements StructuredSerializer { - @override - final Iterable types = const [SpecialModelName, _$SpecialModelName]; +class _$SpecialModelNameSerializer implements StructuredSerializer { + @override + final Iterable types = const [SpecialModelName, _$SpecialModelName]; - @override - final String wireName = r'SpecialModelName'; + @override + final String wireName = r'SpecialModelName'; - @override - Iterable serialize(Serializers serializers, SpecialModelName object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object - .dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket != - null) { - result - ..add(r'$special[property.name]') - ..add(serializers.serialize( - object - .dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, SpecialModelName object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket != null) { + result + ..add(r'$special[property.name]') + ..add(serializers.serialize(object.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket, + specifiedType: const FullType(int))); + } + return result; } - return result; - } - @override - SpecialModelName deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = SpecialModelNameBuilder(); + @override + SpecialModelName deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = SpecialModelNameBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'$special[property.name]': - result.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket = - serializers.deserialize(value, specifiedType: const FullType(int)) - as int; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'$special[property.name]': + result.dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/tag.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/tag.dart index bd591d62aa3..d46c2aa4045 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/tag.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/tag.dart @@ -7,70 +7,73 @@ import 'package:built_value/serializer.dart'; part 'tag.g.dart'; + + abstract class Tag implements Built { - @BuiltValueField(wireName: r'id') - int? get id; + @BuiltValueField(wireName: r'id') + int? get id; - @BuiltValueField(wireName: r'name') - String? get name; + @BuiltValueField(wireName: r'name') + String? get name; - Tag._(); + Tag._(); - static void _initializeBuilder(TagBuilder b) => b; + static void _initializeBuilder(TagBuilder b) => b; - factory Tag([void updates(TagBuilder b)]) = _$Tag; + factory Tag([void updates(TagBuilder b)]) = _$Tag; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$TagSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$TagSerializer(); } class _$TagSerializer implements StructuredSerializer { - @override - final Iterable types = const [Tag, _$Tag]; + @override + final Iterable types = const [Tag, _$Tag]; - @override - final String wireName = r'Tag'; + @override + final String wireName = r'Tag'; - @override - Iterable serialize(Serializers serializers, Tag object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.id != null) { - result - ..add(r'id') - ..add(serializers.serialize(object.id, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, Tag object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.id != null) { + result + ..add(r'id') + ..add(serializers.serialize(object.id, + specifiedType: const FullType(int))); + } + if (object.name != null) { + result + ..add(r'name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(String))); + } + return result; } - if (object.name != null) { - result - ..add(r'name') - ..add(serializers.serialize(object.name, - specifiedType: const FullType(String))); - } - return result; - } - @override - Tag deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = TagBuilder(); + @override + Tag deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = TagBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'name': - result.name = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart index 67cd20d15a4..dec21c7e473 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/lib/src/model/user.dart @@ -7,149 +7,152 @@ import 'package:built_value/serializer.dart'; part 'user.g.dart'; + + abstract class User implements Built { - @BuiltValueField(wireName: r'id') - int? get id; + @BuiltValueField(wireName: r'id') + int? get id; - @BuiltValueField(wireName: r'username') - String? get username; + @BuiltValueField(wireName: r'username') + String? get username; - @BuiltValueField(wireName: r'firstName') - String? get firstName; + @BuiltValueField(wireName: r'firstName') + String? get firstName; - @BuiltValueField(wireName: r'lastName') - String? get lastName; + @BuiltValueField(wireName: r'lastName') + String? get lastName; - @BuiltValueField(wireName: r'email') - String? get email; + @BuiltValueField(wireName: r'email') + String? get email; - @BuiltValueField(wireName: r'password') - String? get password; + @BuiltValueField(wireName: r'password') + String? get password; - @BuiltValueField(wireName: r'phone') - String? get phone; + @BuiltValueField(wireName: r'phone') + String? get phone; - /// User Status - @BuiltValueField(wireName: r'userStatus') - int? get userStatus; + /// User Status + @BuiltValueField(wireName: r'userStatus') + int? get userStatus; - User._(); + User._(); - static void _initializeBuilder(UserBuilder b) => b; + static void _initializeBuilder(UserBuilder b) => b; - factory User([void updates(UserBuilder b)]) = _$User; + factory User([void updates(UserBuilder b)]) = _$User; - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$UserSerializer(); + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$UserSerializer(); } class _$UserSerializer implements StructuredSerializer { - @override - final Iterable types = const [User, _$User]; + @override + final Iterable types = const [User, _$User]; - @override - final String wireName = r'User'; + @override + final String wireName = r'User'; - @override - Iterable serialize(Serializers serializers, User object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - if (object.id != null) { - result - ..add(r'id') - ..add(serializers.serialize(object.id, - specifiedType: const FullType(int))); + @override + Iterable serialize(Serializers serializers, User object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.id != null) { + result + ..add(r'id') + ..add(serializers.serialize(object.id, + specifiedType: const FullType(int))); + } + if (object.username != null) { + result + ..add(r'username') + ..add(serializers.serialize(object.username, + specifiedType: const FullType(String))); + } + if (object.firstName != null) { + result + ..add(r'firstName') + ..add(serializers.serialize(object.firstName, + specifiedType: const FullType(String))); + } + if (object.lastName != null) { + result + ..add(r'lastName') + ..add(serializers.serialize(object.lastName, + specifiedType: const FullType(String))); + } + if (object.email != null) { + result + ..add(r'email') + ..add(serializers.serialize(object.email, + specifiedType: const FullType(String))); + } + if (object.password != null) { + result + ..add(r'password') + ..add(serializers.serialize(object.password, + specifiedType: const FullType(String))); + } + if (object.phone != null) { + result + ..add(r'phone') + ..add(serializers.serialize(object.phone, + specifiedType: const FullType(String))); + } + if (object.userStatus != null) { + result + ..add(r'userStatus') + ..add(serializers.serialize(object.userStatus, + specifiedType: const FullType(int))); + } + return result; } - if (object.username != null) { - result - ..add(r'username') - ..add(serializers.serialize(object.username, - specifiedType: const FullType(String))); - } - if (object.firstName != null) { - result - ..add(r'firstName') - ..add(serializers.serialize(object.firstName, - specifiedType: const FullType(String))); - } - if (object.lastName != null) { - result - ..add(r'lastName') - ..add(serializers.serialize(object.lastName, - specifiedType: const FullType(String))); - } - if (object.email != null) { - result - ..add(r'email') - ..add(serializers.serialize(object.email, - specifiedType: const FullType(String))); - } - if (object.password != null) { - result - ..add(r'password') - ..add(serializers.serialize(object.password, - specifiedType: const FullType(String))); - } - if (object.phone != null) { - result - ..add(r'phone') - ..add(serializers.serialize(object.phone, - specifiedType: const FullType(String))); - } - if (object.userStatus != null) { - result - ..add(r'userStatus') - ..add(serializers.serialize(object.userStatus, - specifiedType: const FullType(int))); - } - return result; - } - @override - User deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = UserBuilder(); + @override + User deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = UserBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case r'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - case r'username': - result.username = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'firstName': - result.firstName = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'lastName': - result.lastName = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'email': - result.email = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'password': - result.password = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'phone': - result.phone = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; - case r'userStatus': - result.userStatus = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - break; - } + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case r'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case r'username': + result.username = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'firstName': + result.firstName = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'lastName': + result.lastName = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'email': + result.email = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'password': + result.password = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'phone': + result.phone = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case r'userStatus': + result.userStatus = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + } + } + return result.build(); } - return result.build(); - } } + diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/pom.xml b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/pom.xml index 511129f20e6..86285381f97 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/pom.xml +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/pom.xml @@ -41,12 +41,6 @@ format - pre-integration-test exec @@ -55,7 +49,11 @@ dart format - --set-exit-if-changed + --output=none . From 6cc270633b057fe97155b2033ede810134c68bfd Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 31 Mar 2021 08:48:12 -0700 Subject: [PATCH 06/99] [python] Fixes additional_properties_type for models (#8802) * Fixes additionalProperties values for models, updates docs, adds tag test of it, fixes frit and gmfruit tests * Moves this.setDisallowAdditionalPropertiesIfNotPresent higher * Makes setting additional_properties_model_instances contingent on the presence of addprosp in schema, updates sample spec composed schemas to remove addprops False form two * Fixes oneOf anyOf allOf instantiation logic * Removes Address from Cat definition * Adds required vars for apple and banana, removes required vars from composed schema init sig * Updates composed schema vars to be set on self and all composed instances * Removes get_unused_args, get_var_name_to_model_instances, and get_additional_properties_model_instances * Fixes fruit + deserilization tests, creates ComposedSchemaWithPropsAndNoAddProps * Fixes FruitReq tests * Fixes GmFruit tests * Fixes discard_unknown_keys tests * Samples updated * Removes additionalproperties False in Child * Samples updated * Improves handling of v2 and v3 specs for isFreeFormObject, v2 sample spec updated with link to bug * Adds cli option disallowAdditionalPropertiesIfNotPresent to python * Adds getAdditionalProperties method so the value for addProps will be correct * Reverts file * Reverts file * Updates python doc * Reverted anytype_3 definition * Updates test_deserialize_lizard * Updates test_deserialize_dict_str_dog * Updates testDog * Updates testChild * Adds v2 python_composition sample * Adds needed files for python testing * Adds existing tests into the new python sample * Fixes test_dog * Removes addProps false form Dog * Fixes testChild * Updates how additionalProperties are set * Fixes empty_map type * Type generation fixed for v2 and v3 specs * Refactors getTypeString, updates artifactids in pom.xml files * Adds new python sample to CI testing I think * Fixes artifactId collision, regenrates docs --- bin/configs/python-oas2.yaml | 5 +- ...allowAdditionalPropertiesIfNotPresent.yaml | 7 + docs/generators/python.md | 2 +- .../languages/PythonClientCodegen.java | 124 +- .../languages/PythonLegacyClientCodegen.java | 1 + .../main/resources/python/model_doc.mustache | 6 +- .../python/model_templates/classvars.mustache | 10 +- .../method_init_composed.mustache | 65 +- .../methods_setattr_getattr_composed.mustache | 67 +- .../resources/python/model_utils.mustache | 182 +- .../options/PythonClientOptionsProvider.java | 13 +- .../PythonLegacyClientOptionsProvider.java | 59 + .../python/PythonClientOptionsTest.java | 4 +- .../python/PythonLegacyClientOptionsTest.java | 54 + ...ith-fake-endpoints-models-for-testing.yaml | 17 +- ...odels-for-testing-with-http-signature.yaml | 30 +- pom.xml | 1 + .../docs/AdditionalPropertiesAnyType.md | 2 +- .../python/docs/AdditionalPropertiesArray.md | 2 +- .../python/docs/AdditionalPropertiesClass.md | 11 +- .../python/docs/AdditionalPropertiesObject.md | 2 +- samples/client/petstore/python/docs/Animal.md | 1 + .../client/petstore/python/docs/AnimalFarm.md | 1 + .../petstore/python/docs/ApiResponse.md | 1 + .../python/docs/ArrayOfArrayOfNumberOnly.md | 1 + .../petstore/python/docs/ArrayOfNumberOnly.md | 1 + .../client/petstore/python/docs/ArrayTest.md | 1 + .../petstore/python/docs/Capitalization.md | 1 + samples/client/petstore/python/docs/Cat.md | 1 + .../client/petstore/python/docs/CatAllOf.md | 1 + .../client/petstore/python/docs/Category.md | 1 + samples/client/petstore/python/docs/Child.md | 1 + .../client/petstore/python/docs/ChildAllOf.md | 1 + .../client/petstore/python/docs/ChildCat.md | 1 + .../petstore/python/docs/ChildCatAllOf.md | 1 + .../client/petstore/python/docs/ChildDog.md | 1 + .../petstore/python/docs/ChildDogAllOf.md | 1 + .../petstore/python/docs/ChildLizard.md | 1 + .../petstore/python/docs/ChildLizardAllOf.md | 1 + .../client/petstore/python/docs/ClassModel.md | 1 + samples/client/petstore/python/docs/Client.md | 1 + samples/client/petstore/python/docs/Dog.md | 1 + .../client/petstore/python/docs/DogAllOf.md | 1 + .../client/petstore/python/docs/EnumArrays.md | 1 + .../client/petstore/python/docs/EnumClass.md | 1 + .../client/petstore/python/docs/EnumTest.md | 1 + samples/client/petstore/python/docs/File.md | 1 + .../python/docs/FileSchemaTestClass.md | 1 + .../client/petstore/python/docs/FormatTest.md | 1 + .../petstore/python/docs/Grandparent.md | 1 + .../petstore/python/docs/GrandparentAnimal.md | 1 + .../petstore/python/docs/HasOnlyReadOnly.md | 1 + samples/client/petstore/python/docs/List.md | 1 + .../client/petstore/python/docs/MapTest.md | 1 + ...dPropertiesAndAdditionalPropertiesClass.md | 1 + .../petstore/python/docs/Model200Response.md | 1 + .../petstore/python/docs/ModelReturn.md | 1 + samples/client/petstore/python/docs/Name.md | 1 + .../client/petstore/python/docs/NumberOnly.md | 1 + .../python/docs/NumberWithValidations.md | 1 + .../python/docs/ObjectModelWithRefProps.md | 1 + samples/client/petstore/python/docs/Order.md | 1 + samples/client/petstore/python/docs/Parent.md | 1 + .../petstore/python/docs/ParentAllOf.md | 1 + .../client/petstore/python/docs/ParentPet.md | 1 + samples/client/petstore/python/docs/Pet.md | 1 + samples/client/petstore/python/docs/Player.md | 1 + .../petstore/python/docs/ReadOnlyFirst.md | 1 + .../petstore/python/docs/SpecialModelName.md | 1 + .../client/petstore/python/docs/StringEnum.md | 1 + samples/client/petstore/python/docs/Tag.md | 1 + .../petstore/python/docs/TypeHolderDefault.md | 1 + .../petstore/python/docs/TypeHolderExample.md | 1 + samples/client/petstore/python/docs/User.md | 1 + .../client/petstore/python/docs/XmlItem.md | 1 + .../model/additional_properties_any_type.py | 2 +- .../model/additional_properties_array.py | 2 +- .../model/additional_properties_class.py | 28 +- .../model/additional_properties_object.py | 2 +- .../python/petstore_api/model/animal.py | 9 +- .../python/petstore_api/model/animal_farm.py | 9 +- .../python/petstore_api/model/api_response.py | 8 +- .../model/array_of_array_of_number_only.py | 8 +- .../model/array_of_number_only.py | 8 +- .../python/petstore_api/model/array_test.py | 9 +- .../petstore_api/model/capitalization.py | 8 +- .../petstore/python/petstore_api/model/cat.py | 31 +- .../python/petstore_api/model/cat_all_of.py | 8 +- .../python/petstore_api/model/category.py | 8 +- .../python/petstore_api/model/child.py | 24 +- .../python/petstore_api/model/child_all_of.py | 8 +- .../python/petstore_api/model/child_cat.py | 31 +- .../petstore_api/model/child_cat_all_of.py | 8 +- .../python/petstore_api/model/child_dog.py | 31 +- .../petstore_api/model/child_dog_all_of.py | 8 +- .../python/petstore_api/model/child_lizard.py | 31 +- .../petstore_api/model/child_lizard_all_of.py | 8 +- .../python/petstore_api/model/class_model.py | 8 +- .../python/petstore_api/model/client.py | 8 +- .../petstore/python/petstore_api/model/dog.py | 31 +- .../python/petstore_api/model/dog_all_of.py | 8 +- .../python/petstore_api/model/enum_arrays.py | 8 +- .../python/petstore_api/model/enum_class.py | 8 +- .../python/petstore_api/model/enum_test.py | 9 +- .../python/petstore_api/model/file.py | 8 +- .../model/file_schema_test_class.py | 9 +- .../python/petstore_api/model/format_test.py | 8 +- .../python/petstore_api/model/grandparent.py | 8 +- .../petstore_api/model/grandparent_animal.py | 9 +- .../petstore_api/model/has_only_read_only.py | 8 +- .../python/petstore_api/model/list.py | 8 +- .../python/petstore_api/model/map_test.py | 9 +- ...perties_and_additional_properties_class.py | 9 +- .../petstore_api/model/model200_response.py | 8 +- .../python/petstore_api/model/model_return.py | 8 +- .../python/petstore_api/model/name.py | 8 +- .../python/petstore_api/model/number_only.py | 8 +- .../model/number_with_validations.py | 8 +- .../model/object_model_with_ref_props.py | 9 +- .../python/petstore_api/model/order.py | 8 +- .../python/petstore_api/model/parent.py | 24 +- .../petstore_api/model/parent_all_of.py | 8 +- .../python/petstore_api/model/parent_pet.py | 31 +- .../petstore/python/petstore_api/model/pet.py | 9 +- .../python/petstore_api/model/player.py | 8 +- .../petstore_api/model/read_only_first.py | 8 +- .../petstore_api/model/special_model_name.py | 8 +- .../python/petstore_api/model/string_enum.py | 8 +- .../petstore/python/petstore_api/model/tag.py | 8 +- .../petstore_api/model/type_holder_default.py | 8 +- .../petstore_api/model/type_holder_example.py | 8 +- .../python/petstore_api/model/user.py | 8 +- .../python/petstore_api/model/xml_item.py | 8 +- .../python/petstore_api/model_utils.py | 249 +- samples/client/petstore/python/pom.xml | 4 +- .../client/petstore/python/test/test_child.py | 39 +- .../client/petstore/python/test/test_dog.py | 46 +- .../.gitignore | 66 + .../.gitlab-ci.yml | 24 + .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 160 ++ .../.openapi-generator/VERSION | 1 + .../.travis.yml | 13 + .../Makefile | 18 + .../README.md | 247 ++ .../dev-requirements.txt | 2 + .../docs/AdditionalPropertiesAnyType.md | 12 + .../docs/AdditionalPropertiesArray.md | 12 + .../docs/AdditionalPropertiesBoolean.md | 12 + .../docs/AdditionalPropertiesClass.md | 21 + .../docs/AdditionalPropertiesInteger.md | 12 + .../docs/AdditionalPropertiesNumber.md | 12 + .../docs/AdditionalPropertiesObject.md | 12 + .../docs/AdditionalPropertiesString.md | 12 + .../docs/Animal.md | 12 + .../docs/AnimalFarm.md | 11 + .../docs/AnotherFakeApi.md | 76 + .../docs/ApiResponse.md | 13 + .../docs/ArrayOfArrayOfNumberOnly.md | 11 + .../docs/ArrayOfNumberOnly.md | 11 + .../docs/ArrayTest.md | 13 + .../docs/Capitalization.md | 16 + .../docs/Cat.md | 13 + .../docs/CatAllOf.md | 11 + .../docs/Category.md | 12 + .../docs/Child.md | 13 + .../docs/ChildAllOf.md | 11 + .../docs/ChildCat.md | 12 + .../docs/ChildCatAllOf.md | 11 + .../docs/ChildDog.md | 12 + .../docs/ChildDogAllOf.md | 11 + .../docs/ChildLizard.md | 12 + .../docs/ChildLizardAllOf.md | 11 + .../docs/ClassModel.md | 12 + .../docs/Client.md | 11 + .../docs/Dog.md | 13 + .../docs/DogAllOf.md | 11 + .../docs/EnumArrays.md | 12 + .../docs/EnumClass.md | 11 + .../docs/EnumTest.md | 15 + .../docs/FakeApi.md | 1205 +++++++++ .../docs/FakeClassnameTags123Api.md | 87 + .../docs/File.md | 12 + .../docs/FileSchemaTestClass.md | 12 + .../docs/FormatTest.md | 23 + .../docs/Grandparent.md | 11 + .../docs/GrandparentAnimal.md | 11 + .../docs/HasOnlyReadOnly.md | 12 + .../docs/List.md | 11 + .../docs/MapTest.md | 14 + ...dPropertiesAndAdditionalPropertiesClass.md | 13 + .../docs/Model200Response.md | 13 + .../docs/ModelReturn.md | 12 + .../docs/Name.md | 15 + .../docs/NumberOnly.md | 11 + .../docs/NumberWithValidations.md | 11 + .../docs/ObjectModelWithRefProps.md | 14 + .../docs/Order.md | 16 + .../docs/Parent.md | 12 + .../docs/ParentAllOf.md | 11 + .../docs/ParentPet.md | 11 + .../docs/Pet.md | 16 + .../docs/PetApi.md | 782 ++++++ .../docs/Player.md | 12 + .../docs/ReadOnlyFirst.md | 12 + .../docs/SpecialModelName.md | 11 + .../docs/StoreApi.md | 285 +++ .../docs/StringBooleanMap.md | 11 + .../docs/StringEnum.md | 11 + .../docs/Tag.md | 13 + .../docs/TypeHolderDefault.md | 18 + .../docs/TypeHolderExample.md | 16 + .../docs/User.md | 18 + .../docs/UserApi.md | 562 +++++ .../docs/XmlItem.md | 39 + .../git_push.sh | 58 + .../petstore_api/__init__.py | 27 + .../petstore_api/api/__init__.py | 3 + .../petstore_api/api/another_fake_api.py | 155 ++ .../petstore_api/api/fake_api.py | 2223 +++++++++++++++++ .../api/fake_classname_tags_123_api.py | 157 ++ .../petstore_api/api/pet_api.py | 1170 +++++++++ .../petstore_api/api/store_api.py | 499 ++++ .../petstore_api/api/user_api.py | 962 +++++++ .../petstore_api/api_client.py | 849 +++++++ .../petstore_api/apis/__init__.py | 22 + .../petstore_api/configuration.py | 511 ++++ .../petstore_api/exceptions.py | 159 ++ .../petstore_api/model/__init__.py | 5 + .../model/additional_properties_any_type.py | 172 ++ .../model/additional_properties_array.py | 172 ++ .../model/additional_properties_boolean.py | 172 ++ .../model/additional_properties_class.py | 196 ++ .../model/additional_properties_integer.py | 172 ++ .../model/additional_properties_number.py | 172 ++ .../model/additional_properties_object.py | 172 ++ .../model/additional_properties_string.py | 172 ++ .../petstore_api/model/animal.py | 185 ++ .../petstore_api/model/animal_farm.py | 184 ++ .../petstore_api/model/api_response.py | 172 ++ .../model/array_of_array_of_number_only.py | 166 ++ .../model/array_of_number_only.py | 166 ++ .../petstore_api/model/array_test.py | 177 ++ .../petstore_api/model/capitalization.py | 181 ++ .../petstore_api/model/cat.py | 218 ++ .../petstore_api/model/cat_all_of.py | 166 ++ .../petstore_api/model/category.py | 173 ++ .../petstore_api/model/child.py | 215 ++ .../petstore_api/model/child_all_of.py | 166 ++ .../petstore_api/model/child_cat.py | 215 ++ .../petstore_api/model/child_cat_all_of.py | 166 ++ .../petstore_api/model/child_dog.py | 215 ++ .../petstore_api/model/child_dog_all_of.py | 166 ++ .../petstore_api/model/child_lizard.py | 215 ++ .../petstore_api/model/child_lizard_all_of.py | 166 ++ .../petstore_api/model/class_model.py | 166 ++ .../petstore_api/model/client.py | 166 ++ .../petstore_api/model/dog.py | 218 ++ .../petstore_api/model/dog_all_of.py | 166 ++ .../petstore_api/model/enum_arrays.py | 177 ++ .../petstore_api/model/enum_class.py | 180 ++ .../petstore_api/model/enum_test.py | 204 ++ .../petstore_api/model/file.py | 166 ++ .../model/file_schema_test_class.py | 174 ++ .../petstore_api/model/format_test.py | 243 ++ .../petstore_api/model/grandparent.py | 166 ++ .../petstore_api/model/grandparent_animal.py | 188 ++ .../petstore_api/model/has_only_read_only.py | 169 ++ .../petstore_api/model/list.py | 166 ++ .../petstore_api/model/map_test.py | 184 ++ ...perties_and_additional_properties_class.py | 177 ++ .../petstore_api/model/model200_response.py | 169 ++ .../petstore_api/model/model_return.py | 166 ++ .../petstore_api/model/name.py | 178 ++ .../petstore_api/model/number_only.py | 166 ++ .../model/number_with_validations.py | 183 ++ .../model/object_model_with_ref_props.py | 177 ++ .../petstore_api/model/order.py | 186 ++ .../petstore_api/model/parent.py | 212 ++ .../petstore_api/model/parent_all_of.py | 166 ++ .../petstore_api/model/parent_pet.py | 219 ++ .../petstore_api/model/pet.py | 197 ++ .../petstore_api/model/player.py | 172 ++ .../petstore_api/model/read_only_first.py | 169 ++ .../petstore_api/model/special_model_name.py | 166 ++ .../petstore_api/model/string_boolean_map.py | 169 ++ .../petstore_api/model/string_enum.py | 184 ++ .../petstore_api/model/tag.py | 172 ++ .../petstore_api/model/type_holder_default.py | 195 ++ .../petstore_api/model/type_holder_example.py | 197 ++ .../petstore_api/model/user.py | 187 ++ .../petstore_api/model/xml_item.py | 250 ++ .../petstore_api/model_utils.py | 1848 ++++++++++++++ .../petstore_api/models/__init__.py | 74 + .../petstore_api/rest.py | 292 +++ .../pom.xml | 46 + .../requirements.txt | 3 + .../setup.cfg | 2 + .../setup.py | 43 + .../test-requirements.txt | 1 + .../test/__init__.py | 0 .../test_additional_properties_any_type.py | 38 + .../test/test_additional_properties_array.py | 50 + .../test_additional_properties_boolean.py | 45 + .../test/test_additional_properties_class.py | 38 + .../test_additional_properties_integer.py | 45 + .../test/test_additional_properties_number.py | 45 + .../test/test_additional_properties_object.py | 50 + .../test/test_additional_properties_string.py | 45 + .../test/test_animal.py | 48 + .../test/test_animal_farm.py | 43 + .../test/test_another_fake_api.py | 39 + .../test/test_api_response.py | 38 + .../test_array_of_array_of_number_only.py | 38 + .../test/test_array_of_number_only.py | 38 + .../test/test_array_test.py | 43 + .../test/test_capitalization.py | 38 + .../test/test_cat.py | 48 + .../test/test_cat_all_of.py | 38 + .../test/test_category.py | 38 + .../test/test_child.py | 57 + .../test/test_child_all_of.py | 38 + .../test/test_child_cat.py | 48 + .../test/test_child_cat_all_of.py | 38 + .../test/test_child_dog.py | 48 + .../test/test_child_dog_all_of.py | 38 + .../test/test_child_lizard.py | 48 + .../test/test_child_lizard_all_of.py | 38 + .../test/test_class_model.py | 38 + .../test/test_client.py | 38 + .../test/test_dog.py | 57 + .../test/test_dog_all_of.py | 38 + .../test/test_enum_arrays.py | 162 ++ .../test/test_enum_class.py | 38 + .../test/test_enum_test.py | 43 + .../test/test_fake_api.py | 197 ++ .../test/test_fake_classname_tags_123_api.py | 39 + .../test/test_file.py | 38 + .../test/test_file_schema_test_class.py | 43 + .../test/test_format_test.py | 153 ++ .../test/test_grandparent.py | 38 + .../test/test_grandparent_animal.py | 58 + .../test/test_has_only_read_only.py | 38 + .../test/test_list.py | 38 + .../test/test_map_test.py | 125 + ...perties_and_additional_properties_class.py | 43 + .../test/test_model200_response.py | 38 + .../test/test_model_return.py | 38 + .../test/test_name.py | 38 + .../test/test_number_only.py | 38 + .../test/test_number_with_validations.py | 45 + .../test/test_object_model_with_ref_props.py | 49 + .../test/test_order.py | 41 + .../test/test_parent.py | 48 + .../test/test_parent_all_of.py | 38 + .../test/test_parent_pet.py | 58 + .../test/test_pet.py | 89 + .../test/test_pet_api.py | 95 + .../test/test_player.py | 44 + .../test/test_read_only_first.py | 38 + .../test/test_special_model_name.py | 38 + .../test/test_store_api.py | 60 + .../test/test_string_boolean_map.py | 38 + .../test/test_string_enum.py | 49 + .../test/test_tag.py | 38 + .../test/test_type_holder_default.py | 41 + .../test/test_type_holder_example.py | 38 + .../test/test_user.py | 38 + .../test/test_user_api.py | 88 + .../test/test_xml_item.py | 38 + .../test_python.sh | 31 + .../testfiles/1px_pic1.png | Bin 0 -> 67 bytes .../testfiles/1px_pic2.png | Bin 0 -> 67 bytes .../testfiles/foo.png | Bin 0 -> 43280 bytes .../tests/__init__.py | 0 .../tests/test_api_client.py | 221 ++ .../tests/test_api_exception.py | 86 + .../tests/test_deserialization.py | 442 ++++ .../tests/test_pet_api.py | 406 +++ .../tests/test_serialization.py | 78 + .../tests/test_store_api.py | 32 + .../tests/util.py | 8 + .../tox.ini | 9 + .../python/x_auth_id_alias/model_utils.py | 249 +- .../python/dynamic_servers/model_utils.py | 249 +- .../petstore/python-experimental/.coverage | Bin 0 -> 94208 bytes .../client/petstore/python-legacy/pom.xml | 2 +- .../petstore/python/.openapi-generator/FILES | 2 + .../openapi3/client/petstore/python/README.md | 1 + .../python/docs/AdditionalPropertiesClass.md | 3 +- .../AdditionalPropertiesWithArrayOfEnums.md | 2 +- .../client/petstore/python/docs/Animal.md | 1 + .../client/petstore/python/docs/AnimalFarm.md | 1 + .../petstore/python/docs/ApiResponse.md | 1 + .../client/petstore/python/docs/Apple.md | 3 +- .../python/docs/ArrayOfArrayOfNumberOnly.md | 1 + .../petstore/python/docs/ArrayOfEnums.md | 1 + .../petstore/python/docs/ArrayOfNumberOnly.md | 1 + .../client/petstore/python/docs/ArrayTest.md | 1 + .../client/petstore/python/docs/Banana.md | 3 +- .../client/petstore/python/docs/BasquePig.md | 1 + .../petstore/python/docs/Capitalization.md | 1 + .../client/petstore/python/docs/CatAllOf.md | 1 + .../client/petstore/python/docs/Category.md | 1 + .../petstore/python/docs/ChildCatAllOf.md | 1 + .../client/petstore/python/docs/ClassModel.md | 1 + .../client/petstore/python/docs/Client.md | 1 + .../ComposedSchemaWithPropsAndNoAddProps.md | 13 + .../client/petstore/python/docs/DanishPig.md | 1 + .../client/petstore/python/docs/DogAllOf.md | 1 + .../client/petstore/python/docs/Drawing.md | 2 +- .../client/petstore/python/docs/EnumArrays.md | 1 + .../client/petstore/python/docs/EnumClass.md | 1 + .../client/petstore/python/docs/EnumTest.md | 1 + .../client/petstore/python/docs/File.md | 1 + .../python/docs/FileSchemaTestClass.md | 1 + .../client/petstore/python/docs/Foo.md | 1 + .../client/petstore/python/docs/FormatTest.md | 1 + .../client/petstore/python/docs/Fruit.md | 6 +- .../client/petstore/python/docs/FruitReq.md | 2 + .../client/petstore/python/docs/GmFruit.md | 5 +- .../petstore/python/docs/GrandparentAnimal.md | 1 + .../petstore/python/docs/HasOnlyReadOnly.md | 1 + .../petstore/python/docs/HealthCheckResult.md | 1 + .../python/docs/InlineResponseDefault.md | 1 + .../petstore/python/docs/IntegerEnum.md | 1 + .../python/docs/IntegerEnumOneValue.md | 1 + .../docs/IntegerEnumWithDefaultValue.md | 1 + .../petstore/python/docs/IsoscelesTriangle.md | 1 + .../client/petstore/python/docs/List.md | 1 + .../client/petstore/python/docs/MapTest.md | 1 + ...dPropertiesAndAdditionalPropertiesClass.md | 1 + .../petstore/python/docs/Model200Response.md | 1 + .../petstore/python/docs/ModelReturn.md | 1 + .../client/petstore/python/docs/Name.md | 1 + .../petstore/python/docs/NullableClass.md | 3 +- .../client/petstore/python/docs/NumberOnly.md | 1 + .../python/docs/NumberWithValidations.md | 1 + .../python/docs/ObjectModelWithRefProps.md | 1 + .../client/petstore/python/docs/Order.md | 1 + .../client/petstore/python/docs/Pet.md | 1 + .../python/docs/QuadrilateralInterface.md | 1 + .../petstore/python/docs/ReadOnlyFirst.md | 1 + .../petstore/python/docs/ShapeInterface.md | 1 + .../petstore/python/docs/SpecialModelName.md | 1 + .../client/petstore/python/docs/StringEnum.md | 1 + .../python/docs/StringEnumWithDefaultValue.md | 1 + .../client/petstore/python/docs/Tag.md | 1 + .../petstore/python/docs/TriangleInterface.md | 1 + .../client/petstore/python/docs/User.md | 1 + .../client/petstore/python/docs/Whale.md | 1 + .../model/additional_properties_class.py | 12 +- .../python/petstore_api/model/animal.py | 9 +- .../python/petstore_api/model/animal_farm.py | 9 +- .../python/petstore_api/model/api_response.py | 8 +- .../python/petstore_api/model/apple.py | 15 +- .../model/array_of_array_of_number_only.py | 8 +- .../petstore_api/model/array_of_enums.py | 9 +- .../model/array_of_number_only.py | 8 +- .../python/petstore_api/model/array_test.py | 9 +- .../python/petstore_api/model/banana.py | 15 +- .../python/petstore_api/model/basque_pig.py | 8 +- .../petstore_api/model/capitalization.py | 8 +- .../petstore/python/petstore_api/model/cat.py | 25 +- .../python/petstore_api/model/cat_all_of.py | 8 +- .../python/petstore_api/model/category.py | 8 +- .../python/petstore_api/model/child_cat.py | 22 +- .../petstore_api/model/child_cat_all_of.py | 8 +- .../python/petstore_api/model/class_model.py | 8 +- .../python/petstore_api/model/client.py | 8 +- .../model/complex_quadrilateral.py | 23 +- ...composed_one_of_number_with_validations.py | 15 +- ...osed_schema_with_props_and_no_add_props.py | 212 ++ .../python/petstore_api/model/danish_pig.py | 8 +- .../petstore/python/petstore_api/model/dog.py | 22 +- .../python/petstore_api/model/dog_all_of.py | 8 +- .../python/petstore_api/model/enum_arrays.py | 8 +- .../python/petstore_api/model/enum_class.py | 8 +- .../python/petstore_api/model/enum_test.py | 9 +- .../model/equilateral_triangle.py | 23 +- .../python/petstore_api/model/file.py | 8 +- .../model/file_schema_test_class.py | 9 +- .../petstore/python/petstore_api/model/foo.py | 8 +- .../python/petstore_api/model/format_test.py | 8 +- .../python/petstore_api/model/fruit.py | 36 +- .../python/petstore_api/model/fruit_req.py | 24 +- .../python/petstore_api/model/gm_fruit.py | 36 +- .../petstore_api/model/grandparent_animal.py | 9 +- .../petstore_api/model/has_only_read_only.py | 8 +- .../petstore_api/model/health_check_result.py | 8 +- .../model/inline_response_default.py | 9 +- .../python/petstore_api/model/integer_enum.py | 8 +- .../model/integer_enum_one_value.py | 8 +- .../model/integer_enum_with_default_value.py | 8 +- .../petstore_api/model/isosceles_triangle.py | 32 +- .../python/petstore_api/model/list.py | 8 +- .../python/petstore_api/model/mammal.py | 22 +- .../python/petstore_api/model/map_test.py | 9 +- ...perties_and_additional_properties_class.py | 9 +- .../petstore_api/model/model200_response.py | 8 +- .../python/petstore_api/model/model_return.py | 8 +- .../python/petstore_api/model/name.py | 8 +- .../petstore_api/model/nullable_class.py | 5 +- .../petstore_api/model/nullable_shape.py | 22 +- .../python/petstore_api/model/number_only.py | 8 +- .../model/number_with_validations.py | 8 +- .../model/object_model_with_ref_props.py | 9 +- .../python/petstore_api/model/order.py | 8 +- .../python/petstore_api/model/parent_pet.py | 22 +- .../petstore/python/petstore_api/model/pet.py | 9 +- .../petstore/python/petstore_api/model/pig.py | 22 +- .../petstore_api/model/quadrilateral.py | 22 +- .../model/quadrilateral_interface.py | 8 +- .../petstore_api/model/read_only_first.py | 8 +- .../petstore_api/model/scalene_triangle.py | 23 +- .../python/petstore_api/model/shape.py | 22 +- .../petstore_api/model/shape_interface.py | 8 +- .../petstore_api/model/shape_or_null.py | 22 +- .../model/simple_quadrilateral.py | 23 +- .../python/petstore_api/model/some_object.py | 15 +- .../petstore_api/model/special_model_name.py | 8 +- .../python/petstore_api/model/string_enum.py | 8 +- .../model/string_enum_with_default_value.py | 8 +- .../petstore/python/petstore_api/model/tag.py | 8 +- .../python/petstore_api/model/triangle.py | 22 +- .../petstore_api/model/triangle_interface.py | 8 +- .../python/petstore_api/model/user.py | 8 +- .../python/petstore_api/model/whale.py | 8 +- .../python/petstore_api/model_utils.py | 249 +- .../python/petstore_api/models/__init__.py | 1 + .../openapi3/client/petstore/python/pom.xml | 4 +- ...osed_schema_with_props_and_no_add_props.py | 37 + ...osed_schema_with_props_and_no_add_props.py | 45 + .../tests_manual/test_deserialization.py | 9 +- .../test_discard_unknown_properties.py | 44 +- .../python/tests_manual/test_fruit.py | 153 +- .../python/tests_manual/test_fruit_req.py | 80 +- .../python/tests_manual/test_gm_fruit.py | 115 +- .../petstore/python/tests_manual/test_tag.py | 35 + 539 files changed, 32476 insertions(+), 1617 deletions(-) create mode 100644 bin/configs/python-oas2_disallowAdditionalPropertiesIfNotPresent.yaml create mode 100644 modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonLegacyClientOptionsProvider.java create mode 100644 modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonLegacyClientOptionsTest.java create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitignore create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitlab-ci.yml create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator-ignore create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.travis.yml create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/Makefile create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/README.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/dev-requirements.txt create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesAnyType.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesArray.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesBoolean.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesClass.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesInteger.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesNumber.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesObject.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesString.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Animal.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnimalFarm.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnotherFakeApi.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ApiResponse.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfArrayOfNumberOnly.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfNumberOnly.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayTest.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Capitalization.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Cat.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/CatAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Category.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Child.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCat.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCatAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDog.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDogAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizard.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizardAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ClassModel.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Client.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Dog.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/DogAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumArrays.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumClass.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumTest.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeClassnameTags123Api.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/File.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FileSchemaTestClass.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FormatTest.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Grandparent.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/GrandparentAnimal.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/HasOnlyReadOnly.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/List.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MapTest.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MixedPropertiesAndAdditionalPropertiesClass.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Model200Response.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ModelReturn.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Name.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberOnly.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberWithValidations.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ObjectModelWithRefProps.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Order.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Parent.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentAllOf.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentPet.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Pet.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/PetApi.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Player.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ReadOnlyFirst.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/SpecialModelName.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StoreApi.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringBooleanMap.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringEnum.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Tag.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderDefault.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderExample.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/User.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/UserApi.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/XmlItem.md create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/git_push.sh create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/another_fake_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags_123_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/pet_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/store_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/user_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/apis/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/configuration.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/exceptions.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_any_type.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_array.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_boolean.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_integer.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_object.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_string.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal_farm.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/api_response.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_array_of_number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/capitalization.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/category.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/class_model.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/client.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_arrays.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file_schema_test_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/format_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent_animal.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/has_only_read_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/list.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/map_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/mixed_properties_and_additional_properties_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model200_response.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model_return.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/name.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_with_validations.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/object_model_with_ref_props.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/order.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_pet.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/pet.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/player.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/read_only_first.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/special_model_name.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_boolean_map.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_enum.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/tag.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_default.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_example.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/user.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/xml_item.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/models/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/pom.xml create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/requirements.txt create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.cfg create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test-requirements.txt create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_any_type.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_array.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_boolean.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_integer.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_number.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_object.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_string.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal_farm.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_another_fake_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_api_response.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_array_of_number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_capitalization.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_category.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_class_model.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_client.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_arrays.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_classname_tags_123_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file_schema_test_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_format_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent_animal.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_has_only_read_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_list.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_map_test.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_mixed_properties_and_additional_properties_class.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model200_response.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model_return.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_name.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_only.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_with_validations.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_object_model_with_ref_props.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_order.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_all_of.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_pet.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_player.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_read_only_first.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_special_model_name.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_store_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_boolean_map.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_enum.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_tag.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_default.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_example.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_xml_item.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test_python.sh create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic1.png create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic2.png create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/foo.png create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/__init__.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_exception.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_deserialization.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_pet_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_serialization.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_store_api.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/util.py create mode 100644 samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tox.ini create mode 100644 samples/openapi3/client/petstore/python-experimental/.coverage create mode 100644 samples/openapi3/client/petstore/python/docs/ComposedSchemaWithPropsAndNoAddProps.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/composed_schema_with_props_and_no_add_props.py create mode 100644 samples/openapi3/client/petstore/python/test/test_composed_schema_with_props_and_no_add_props.py create mode 100644 samples/openapi3/client/petstore/python/tests_manual/test_composed_schema_with_props_and_no_add_props.py create mode 100644 samples/openapi3/client/petstore/python/tests_manual/test_tag.py diff --git a/bin/configs/python-oas2.yaml b/bin/configs/python-oas2.yaml index 4555376bd16..7c548fb3926 100644 --- a/bin/configs/python-oas2.yaml +++ b/bin/configs/python-oas2.yaml @@ -1,7 +1,10 @@ +# this file exists because in this file we omit setting disallowAdditionalPropertiesIfNotPresent +# which makes it default to false +# that false setting is needed for composed schemas to work +# Composed schemas are schemas that contain the allOf/oneOf/anyOf keywords. v2 specs only support the allOf keyword. generatorName: python outputDir: samples/client/petstore/python inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml templateDir: modules/openapi-generator/src/main/resources/python additionalProperties: - disallowAdditionalPropertiesIfNotPresent: "true" packageName: petstore_api diff --git a/bin/configs/python-oas2_disallowAdditionalPropertiesIfNotPresent.yaml b/bin/configs/python-oas2_disallowAdditionalPropertiesIfNotPresent.yaml new file mode 100644 index 00000000000..841cf77854e --- /dev/null +++ b/bin/configs/python-oas2_disallowAdditionalPropertiesIfNotPresent.yaml @@ -0,0 +1,7 @@ +generatorName: python +outputDir: samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent +inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/python +additionalProperties: + disallowAdditionalPropertiesIfNotPresent: "true" + packageName: petstore_api diff --git a/docs/generators/python.md b/docs/generators/python.md index 4cf503ff278..fe60f0e511c 100644 --- a/docs/generators/python.md +++ b/docs/generators/python.md @@ -7,6 +7,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | +|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. NOTE: this option breaks composition and will be removed in 6.0.0
|false| |generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false| |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| |library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3| @@ -28,7 +29,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Type/Alias | Instantiated By | | ---------- | --------------- | -|map|dict| ## LANGUAGE PRIMITIVES diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index b38d2448d87..9b9f8b6da4b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -65,10 +65,6 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { // in other code generators, support needs to be enabled on a case-by-case basis. supportsAdditionalPropertiesWithComposedSchema = true; - // When the 'additionalProperties' keyword is not present in a OAS schema, allow - // undeclared properties. This is compliant with the JSON schema specification. - this.setDisallowAdditionalPropertiesIfNotPresent(false); - modifyFeatureSet(features -> features .includeDocumentationFeatures(DocumentationFeature.Readme) .wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML, WireFormatFeature.Custom)) @@ -94,9 +90,8 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { ParameterFeature.Cookie ) ); - - // this may set datatype right for additional properties - instantiationTypes.put("map", "dict"); + // needed for type object with additionalProperties: false + typeMapping.put("object", "dict"); languageSpecificPrimitives.add("file_type"); languageSpecificPrimitives.add("none_type"); @@ -111,6 +106,20 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { cliOptions.add(new CliOption(CodegenConstants.PYTHON_ATTR_NONE_IF_UNSET, CodegenConstants.PYTHON_ATTR_NONE_IF_UNSET_DESC) .defaultValue(Boolean.FALSE.toString())); + // option to change how we process + set the data in the 'additionalProperties' keyword. + CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean( + CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, + CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC).defaultValue(Boolean.FALSE.toString()); + Map disallowAdditionalPropertiesIfNotPresentOpts = new HashMap<>(); + disallowAdditionalPropertiesIfNotPresentOpts.put("false", + "The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications."); + disallowAdditionalPropertiesIfNotPresentOpts.put("true", + "Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. NOTE: "+ + "this option breaks composition and will be removed in 6.0.0" + ); + disallowAdditionalPropertiesIfNotPresentOpt.setEnum(disallowAdditionalPropertiesIfNotPresentOpts); + cliOptions.add(disallowAdditionalPropertiesIfNotPresentOpt); + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) .stability(Stability.EXPERIMENTAL) .build(); @@ -160,6 +169,18 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { } additionalProperties.put("attrNoneIfUnset", attrNoneIfUnset); + // When the 'additionalProperties' keyword is not present in a OAS schema, allow + // undeclared properties. This is compliant with the JSON schema specification. + // setting this to false is required to have composed schemas work because: + // anyOf SchemaA + SchemaB, requires that props present only in A are accepted in B because in B + // they are additional properties + Boolean disallowAddProps = false; + if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) { + disallowAddProps = Boolean.valueOf(additionalProperties.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()); + } + this.setDisallowAdditionalPropertiesIfNotPresent(disallowAddProps); + + // check library option to ensure only urllib3 is supported if (!DEFAULT_LIBRARY.equals(getLibrary())) { throw new RuntimeException("Only the `urllib3` library is supported in the refactored `python` client generator at the moment. Please fall back to `python-legacy` client generator for the time being. We welcome contributions to add back `asyncio`, `tornado` support to the `python` client generator."); @@ -728,6 +749,62 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { return null; } + @Override + protected Schema getAdditionalProperties(Schema schema) { + /* + Use cases: + 1. addProps set to schema in spec: return that schema + 2. addProps unset w/ getDisallowAdditionalPropertiesIfNotPresent -> null + 3. addProps unset w/ getDisallowAdditionalPropertiesIfNotPresent=False -> new Schema() + 4. addProps true -> new Schema() NOTE: v3 only + 5. addprops false -> null NOTE: v3 only + */ + Object addProps = schema.getAdditionalProperties(); + if (addProps instanceof Schema) { + return (Schema) addProps; + } + if (addProps == null) { + // When reaching this code path, this should indicate the 'additionalProperties' keyword is + // not present in the OAS schema. This is true for OAS 3.0 documents. + // However, the parsing logic is broken for OAS 2.0 documents because of the + // https://github.com/swagger-api/swagger-parser/issues/1369 issue. + // When OAS 2.0 documents are parsed, the swagger-v2-converter ignores the 'additionalProperties' + // keyword if the value is boolean. That means codegen is unable to determine whether + // additional properties are allowed or not. + // + // The original behavior was to assume additionalProperties had been set to false. + if (getDisallowAdditionalPropertiesIfNotPresent()) { + // If the 'additionalProperties' keyword is not present in a OAS schema, + // interpret as if the 'additionalProperties' keyword had been set to false. + // This is NOT compliant with the JSON schema specification. It is the original + // 'openapi-generator' behavior. + return null; + } + /* + // The disallowAdditionalPropertiesIfNotPresent CLI option has been set to true, + // but for now that only works with OAS 3.0 documents. + // The new behavior does not work with OAS 2.0 documents. + if (extensions == null || !extensions.containsKey(EXTENSION_OPENAPI_DOC_VERSION)) { + // Fallback to the legacy behavior. + return null; + } + // Get original swagger version from OAS extension. + // Note openAPI.getOpenapi() is always set to 3.x even when the document + // is converted from a OAS/Swagger 2.0 document. + // https://github.com/swagger-api/swagger-parser/pull/1374 + SemVer version = new SemVer((String)extensions.get(EXTENSION_OPENAPI_DOC_VERSION)); + if (version.major != 3) { + return null; + } + */ + } + if (addProps == null || (addProps instanceof Boolean && (Boolean) addProps)) { + // Return empty schema to allow any type + return new Schema(); + } + return null; + } + /** * Return a string representation of the Python types for the specified OAS schema. * Primitive types in the OAS specification are implemented in Python using the corresponding @@ -767,16 +844,39 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { } } if (isAnyTypeSchema(p)) { + // for v2 specs only, swagger-parser never generates an AnyType schemas even though it should generate them + // https://github.com/swagger-api/swagger-parser/issues/1378 + // switch to v3 if you need AnyType to work return prefix + "bool, date, datetime, dict, float, int, list, str, none_type" + suffix; } + String originalSpecVersion = "X"; + if (this.openAPI.getExtensions() != null && this.openAPI.getExtensions().containsKey("x-original-swagger-version")) { + originalSpecVersion = (String) this.openAPI.getExtensions().get("x-original-swagger-version"); + originalSpecVersion = originalSpecVersion.substring(0, 1); + + } + Boolean v2DisallowAdditionalPropertiesIfNotPresentAddPropsNullCase = (getAdditionalProperties(p) == null && this.getDisallowAdditionalPropertiesIfNotPresent() && originalSpecVersion.equals("2")); + Schema emptySchema = new Schema(); + Boolean v2WithCompositionAddPropsAnyTypeSchemaCase = (getAdditionalProperties(p) != null && emptySchema.equals(getAdditionalProperties(p)) && originalSpecVersion.equals("2")); + if (isFreeFormObject(p) && (v2DisallowAdditionalPropertiesIfNotPresentAddPropsNullCase || v2WithCompositionAddPropsAnyTypeSchemaCase)) { + // for v2 specs only, input AnyType schemas (type unset) or schema {} results in FreeFromObject schemas + // per https://github.com/swagger-api/swagger-parser/issues/1378 + // v2 spec uses cases + // 1. AnyType schemas + // 2. type object schema with no other info + // use case 1 + 2 -> both become use case 1 + // switch to v3 if you need use cases 1 + 2 to work correctly + return prefix + "bool, date, datetime, dict, float, int, list, str, none_type" + fullSuffix; + } // Resolve $ref because ModelUtils.isXYZ methods do not automatically resolve references. if (ModelUtils.isNullable(ModelUtils.getReferencedSchema(this.openAPI, p))) { fullSuffix = ", none_type" + suffix; } - if (isFreeFormObject(p) && getAdditionalProperties(p) == null) { - return prefix + "bool, date, datetime, dict, float, int, list, str" + fullSuffix; - } - if ((ModelUtils.isMapSchema(p) || "object".equals(p.getType())) && getAdditionalProperties(p) != null) { + Boolean v3WithCompositionAddPropsAnyTypeSchemaCase = (getAdditionalProperties(p) != null && emptySchema.equals(getAdditionalProperties(p)) && originalSpecVersion.equals("3")); + if (isFreeFormObject(p) && v3WithCompositionAddPropsAnyTypeSchemaCase) { + // v3 code path, use case: type object schema with no other schema info + return prefix + "{str: (bool, date, datetime, dict, float, int, list, str, none_type)}" + fullSuffix; + } else if ((ModelUtils.isMapSchema(p) || "object".equals(p.getType())) && getAdditionalProperties(p) != null) { Schema inner = getAdditionalProperties(p); return prefix + "{str: " + getTypeString(inner, "(", ")", referencedModelNames) + "}" + fullSuffix; } else if (ModelUtils.isArraySchema(p)) { @@ -835,7 +935,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { // The 'addProps' may be a reference, getTypeDeclaration will resolve // the reference. List referencedModelNames = new ArrayList(); - codegenModel.additionalPropertiesType = getTypeString(addProps, "", "", referencedModelNames); + getTypeString(addProps, "", "", referencedModelNames); if (referencedModelNames.size() != 0) { // Models that are referenced in the 'additionalPropertiesType' keyword // must be added to the imports. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java index 7d5cc631a8b..ca169e64122 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonLegacyClientCodegen.java @@ -35,6 +35,7 @@ public class PythonLegacyClientCodegen extends AbstractPythonCodegen implements // nose is a python testing framework, we use pytest if USE_NOSE is unset public static final String USE_NOSE = "useNose"; public static final String RECURSION_LIMIT = "recursionLimit"; + public static final String PYTHON_ATTR_NONE_IF_UNSET = "pythonAttrNoneIfUnset"; protected String packageUrl; protected String apiDocPath = "docs/"; diff --git a/modules/openapi-generator/src/main/resources/python/model_doc.mustache b/modules/openapi-generator/src/main/resources/python/model_doc.mustache index ff7358618ea..3f7c8263df2 100644 --- a/modules/openapi-generator/src/main/resources/python/model_doc.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_doc.mustache @@ -28,9 +28,9 @@ Name | Type | Description | Notes {{#optionalVars}} **{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} -{{#additionalPropertiesType}} -**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] -{{/additionalPropertiesType}} +{{#additionalProperties}} +**any string name** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | any string name can be used but the value must be the correct type | [optional] +{{/additionalProperties}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/classvars.mustache b/modules/openapi-generator/src/main/resources/python/model_templates/classvars.mustache index 88ae5df9f12..0e5ff25b97f 100644 --- a/modules/openapi-generator/src/main/resources/python/model_templates/classvars.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_templates/classvars.mustache @@ -60,7 +60,7 @@ {{/optionalVars}} } -{{#additionalPropertiesType}} +{{#additionalProperties}} @cached_property def additional_properties_type(): """ @@ -72,11 +72,11 @@ lazy_import() {{/-first}} {{/imports}} - return ({{{additionalPropertiesType}}},) # noqa: E501 -{{/additionalPropertiesType}} -{{^additionalPropertiesType}} + return ({{{dataType}}},) # noqa: E501 +{{/additionalProperties}} +{{^additionalProperties}} additional_properties_type = None -{{/additionalPropertiesType}} +{{/additionalProperties}} _nullable = {{#isNullable}}True{{/isNullable}}{{^isNullable}}False{{/isNullable}} diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/method_init_composed.mustache b/modules/openapi-generator/src/main/resources/python/model_templates/method_init_composed.mustache index 9b298379710..ca0505ead96 100644 --- a/modules/openapi-generator/src/main/resources/python/model_templates/method_init_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_templates/method_init_composed.mustache @@ -10,7 +10,52 @@ '_additional_properties_model_instances', ]) -{{> model_templates/method_init_shared }} + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, @@ -19,28 +64,18 @@ '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { -{{#requiredVars}} - '{{name}}': {{name}}, -{{/requiredVars}} - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/methods_setattr_getattr_composed.mustache b/modules/openapi-generator/src/main/resources/python/model_templates/methods_setattr_getattr_composed.mustache index 6b1013ca997..de7887ebdbd 100644 --- a/modules/openapi-generator/src/main/resources/python/model_templates/methods_setattr_getattr_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_templates/methods_setattr_getattr_composed.mustache @@ -4,27 +4,43 @@ self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -34,13 +50,12 @@ return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: diff --git a/modules/openapi-generator/src/main/resources/python/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/model_utils.mustache index 07b77a99d18..9b5a8dd9e81 100644 --- a/modules/openapi-generator/src/main/resources/python/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_utils.mustache @@ -1291,8 +1291,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1300,20 +1305,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1373,31 +1366,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1454,24 +1425,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1484,47 +1439,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1568,36 +1510,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonClientOptionsProvider.java index 7beb3ec69c0..fc7d74074dd 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonClientOptionsProvider.java @@ -19,7 +19,7 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.languages.PythonLegacyClientCodegen; +import org.openapitools.codegen.languages.PythonClientCodegen; import java.util.Map; @@ -30,6 +30,8 @@ public class PythonClientOptionsProvider implements OptionsProvider { public static final String PACKAGE_URL_VALUE = ""; public static final String USE_NOSE_VALUE = "false"; public static final String RECURSION_LIMIT = "1200"; + public static final String DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT = "false"; + public static final String PYTHON_ATTR_NONE_IF_UNSET = "false"; @Override public String getLanguage() { @@ -39,16 +41,17 @@ public class PythonClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { ImmutableMap.Builder builder = new ImmutableMap.Builder(); - return builder.put(PythonLegacyClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE) + return builder.put(PythonClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE) .put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE) .put(CodegenConstants.PROJECT_NAME, PROJECT_NAME_VALUE) .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE) - .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true") .put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true") .put(CodegenConstants.SOURCECODEONLY_GENERATION, "false") .put(CodegenConstants.LIBRARY, "urllib3") - .put(PythonLegacyClientCodegen.USE_NOSE, USE_NOSE_VALUE) - .put(PythonLegacyClientCodegen.RECURSION_LIMIT, RECURSION_LIMIT) + .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT) + .put(PythonClientCodegen.USE_NOSE, USE_NOSE_VALUE) + .put(PythonClientCodegen.RECURSION_LIMIT, RECURSION_LIMIT) + .put(PythonClientCodegen.PYTHON_ATTR_NONE_IF_UNSET, PYTHON_ATTR_NONE_IF_UNSET) .build(); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonLegacyClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonLegacyClientOptionsProvider.java new file mode 100644 index 00000000000..90e76caea16 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/PythonLegacyClientOptionsProvider.java @@ -0,0 +1,59 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.options; + +import com.google.common.collect.ImmutableMap; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.languages.PythonLegacyClientCodegen; + +import java.util.Map; + +public class PythonLegacyClientOptionsProvider implements OptionsProvider { + public static final String PACKAGE_NAME_VALUE = "swagger_client_python"; + public static final String PROJECT_NAME_VALUE = "swagger-client-python"; + public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT"; + public static final String PACKAGE_URL_VALUE = ""; + public static final String USE_NOSE_VALUE = "false"; + public static final String RECURSION_LIMIT = "1200"; + + @Override + public String getLanguage() { + return "python"; + } + + @Override + public Map createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder.put(PythonLegacyClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE) + .put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE) + .put(CodegenConstants.PROJECT_NAME, PROJECT_NAME_VALUE) + .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE) + .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true") + .put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true") + .put(CodegenConstants.SOURCECODEONLY_GENERATION, "false") + .put(CodegenConstants.LIBRARY, "urllib3") + .put(PythonLegacyClientCodegen.USE_NOSE, USE_NOSE_VALUE) + .put(PythonLegacyClientCodegen.RECURSION_LIMIT, RECURSION_LIMIT) + .build(); + } + + @Override + public boolean isServer() { + return false; + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientOptionsTest.java index 8bec98892ef..e423c6e8584 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientOptionsTest.java @@ -19,7 +19,7 @@ package org.openapitools.codegen.python; import org.openapitools.codegen.AbstractOptionsTest; import org.openapitools.codegen.CodegenConfig; -import org.openapitools.codegen.languages.PythonLegacyClientCodegen; +import org.openapitools.codegen.languages.PythonClientCodegen; import org.openapitools.codegen.options.PythonClientOptionsProvider; import org.testng.Assert; @@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; public class PythonClientOptionsTest extends AbstractOptionsTest { - private PythonLegacyClientCodegen clientCodegen = mock(PythonLegacyClientCodegen.class, mockSettings); + private PythonClientCodegen clientCodegen = mock(PythonClientCodegen.class, mockSettings); public PythonClientOptionsTest() { super(new PythonClientOptionsProvider()); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonLegacyClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonLegacyClientOptionsTest.java new file mode 100644 index 00000000000..8c17cdbb2fd --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonLegacyClientOptionsTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.python; + +import org.openapitools.codegen.AbstractOptionsTest; +import org.openapitools.codegen.CodegenConfig; +import org.openapitools.codegen.languages.PythonLegacyClientCodegen; +import org.openapitools.codegen.options.PythonLegacyClientOptionsProvider; +import org.testng.Assert; + +import java.io.File; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class PythonLegacyClientOptionsTest extends AbstractOptionsTest { + private PythonLegacyClientCodegen clientCodegen = mock(PythonLegacyClientCodegen.class, mockSettings); + + public PythonLegacyClientOptionsTest() { + super(new PythonLegacyClientOptionsProvider()); + } + + @Override + protected CodegenConfig getCodegenConfig() { + return clientCodegen; + } + + @SuppressWarnings("unused") + @Override + protected void verifyOptions() { + Assert.assertEquals(clientCodegen.packagePath(), PythonLegacyClientOptionsProvider.PACKAGE_NAME_VALUE.replace('.', File.separatorChar)); + + verify(clientCodegen).setPackageName(PythonLegacyClientOptionsProvider.PACKAGE_NAME_VALUE); + verify(clientCodegen).setProjectName(PythonLegacyClientOptionsProvider.PROJECT_NAME_VALUE); + verify(clientCodegen).setPackageVersion(PythonLegacyClientOptionsProvider.PACKAGE_VERSION_VALUE); + verify(clientCodegen).setPackageUrl(PythonLegacyClientOptionsProvider.PACKAGE_URL_VALUE); + verify(clientCodegen).setUseNose(PythonLegacyClientOptionsProvider.USE_NOSE_VALUE); + } +} diff --git a/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml index 9e9451dcc5b..097ae6768bb 100644 --- a/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1373,8 +1373,6 @@ definitions: properties: breed: type: string - additionalProperties: false - additionalProperties: false Cat: allOf: - $ref: '#/definitions/Animal' @@ -1523,8 +1521,7 @@ definitions: type: object additionalProperties: type: array - items: - type: object + items: {} map_map_string: type: object additionalProperties: @@ -1535,14 +1532,15 @@ definitions: type: object additionalProperties: type: object - additionalProperties: - type: object - anytype_1: - type: object - anytype_2: {} + additionalProperties: {} + anytype_1: {} + anytype_2: + description: no type is set for this anytype_3: type: object properties: {} + description: 'because of a bug in swagger-parser, this should have values {str: (str, int, float...)} + but instead we get any type. See https://github.com/swagger-api/swagger-parser/issues/1378' AdditionalPropertiesString: type: object properties: @@ -2091,7 +2089,6 @@ definitions: properties: interNet: type: boolean - additionalProperties: false GrandparentAnimal: type: object required: diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index bd29a22a5f9..631e09dab8a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1584,7 +1584,6 @@ components: Cat: allOf: - $ref: '#/components/schemas/Animal' - - $ref: '#/components/schemas/Address' - type: object properties: declawed: @@ -2037,6 +2036,9 @@ components: items: type: object nullable: true + object_nullable: + type: object + nullable: true object_nullable_prop: type: object nullable: true @@ -2054,18 +2056,27 @@ components: type: object nullable: true additionalProperties: - type: object nullable: true + ComposedSchemaWithPropsAndNoAddProps: + properties: + color: + type: string + allOf: + - $ref: '#/components/schemas/Tag' + # Below additionalProperties is set to false to validate the use + # case when a composed schema has additionalProperties set to false. + # This definition will only allow in object payloads that set color and no other properties because + # additionalProperties are evaluated at the schema level and do not include composed schema + # properties. Only color is defined here, all others are additional + additionalProperties: false fruit: + description: a schema that tests oneOf and includes a schema level property properties: color: type: string oneOf: - $ref: '#/components/schemas/apple' - $ref: '#/components/schemas/banana' - # Below additionalProperties is set to false to validate the use - # case when a composed schema has additionalProperties set to false. - additionalProperties: false apple: type: object properties: @@ -2075,12 +2086,16 @@ components: origin: type: string pattern: /^[A-Z\s]*$/i + required: + - cultivar nullable: true banana: type: object properties: lengthCm: type: number + required: + - lengthCm mammal: oneOf: - $ref: '#/components/schemas/whale' @@ -2140,13 +2155,13 @@ components: anyOf: - $ref: '#/components/schemas/apple' - $ref: '#/components/schemas/banana' - additionalProperties: false fruitReq: + description: a schema where additionalProperties is on in the composed schema and off in the oneOf object schemas + also, this schem accepts null as a value oneOf: - type: 'null' - $ref: '#/components/schemas/appleReq' - $ref: '#/components/schemas/bananaReq' - additionalProperties: false appleReq: type: object properties: @@ -2250,7 +2265,6 @@ components: allOf: - $ref: '#/components/schemas/ShapeInterface' - $ref: '#/components/schemas/TriangleInterface' - additionalProperties: false ScaleneTriangle: allOf: - $ref: '#/components/schemas/ShapeInterface' diff --git a/pom.xml b/pom.xml index 97fbcd3eb61..c571e6b1abe 100644 --- a/pom.xml +++ b/pom.xml @@ -1206,6 +1206,7 @@ samples/client/petstore/javascript-flowtyped samples/client/petstore/python + samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent samples/client/petstore/python-legacy samples/client/petstore/python-asyncio samples/client/petstore/python-tornado diff --git a/samples/client/petstore/python/docs/AdditionalPropertiesAnyType.md b/samples/client/petstore/python/docs/AdditionalPropertiesAnyType.md index a69ff4928f4..d31d12de082 100644 --- a/samples/client/petstore/python/docs/AdditionalPropertiesAnyType.md +++ b/samples/client/petstore/python/docs/AdditionalPropertiesAnyType.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str** | any string name can be used but the value must be the correct type | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/AdditionalPropertiesArray.md b/samples/client/petstore/python/docs/AdditionalPropertiesArray.md index 697494b373f..40537cbf838 100644 --- a/samples/client/petstore/python/docs/AdditionalPropertiesArray.md +++ b/samples/client/petstore/python/docs/AdditionalPropertiesArray.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | [optional] -**any string name** | **[bool, date, datetime, dict, float, int, list, str]** | any string name can be used but the value must be the correct type | [optional] +**any string name** | **[bool, date, datetime, dict, float, int, list, str, none_type]** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/AdditionalPropertiesClass.md b/samples/client/petstore/python/docs/AdditionalPropertiesClass.md index 3646837b853..3ba7bab6f3d 100644 --- a/samples/client/petstore/python/docs/AdditionalPropertiesClass.md +++ b/samples/client/petstore/python/docs/AdditionalPropertiesClass.md @@ -9,12 +9,13 @@ Name | Type | Description | Notes **map_integer** | **{str: (int,)}** | | [optional] **map_boolean** | **{str: (bool,)}** | | [optional] **map_array_integer** | **{str: ([int],)}** | | [optional] -**map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str],)}** | | [optional] +**map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str, none_type],)}** | | [optional] **map_map_string** | **{str: ({str: (str,)},)}** | | [optional] -**map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}** | | [optional] -**anytype_1** | **bool, date, datetime, dict, float, int, list, str** | | [optional] -**anytype_2** | **bool, date, datetime, dict, float, int, list, str** | | [optional] -**anytype_3** | **bool, date, datetime, dict, float, int, list, str** | | [optional] +**map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)}** | | [optional] +**anytype_1** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**anytype_2** | **bool, date, datetime, dict, float, int, list, str, none_type** | no type is set for this | [optional] +**anytype_3** | **bool, date, datetime, dict, float, int, list, str, none_type** | because of a bug in swagger-parser, this should have values {str: (str, int, float...)} but instead we get any type. See https://github.com/swagger-api/swagger-parser/issues/1378 | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/AdditionalPropertiesObject.md b/samples/client/petstore/python/docs/AdditionalPropertiesObject.md index 73ba5914712..dc64a0d91c2 100644 --- a/samples/client/petstore/python/docs/AdditionalPropertiesObject.md +++ b/samples/client/petstore/python/docs/AdditionalPropertiesObject.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | [optional] -**any string name** | **{str: (bool, date, datetime, dict, float, int, list, str,)}** | any string name can be used but the value must be the correct type | [optional] +**any string name** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type,)}** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Animal.md b/samples/client/petstore/python/docs/Animal.md index 1d1c77c01ab..d36c66a5d88 100644 --- a/samples/client/petstore/python/docs/Animal.md +++ b/samples/client/petstore/python/docs/Animal.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/AnimalFarm.md b/samples/client/petstore/python/docs/AnimalFarm.md index fc299cf27d3..fb3b33c9c9c 100644 --- a/samples/client/petstore/python/docs/AnimalFarm.md +++ b/samples/client/petstore/python/docs/AnimalFarm.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | [**[Animal]**](Animal.md) | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ApiResponse.md b/samples/client/petstore/python/docs/ApiResponse.md index 81a7d0d8522..bedefea9a9c 100644 --- a/samples/client/petstore/python/docs/ApiResponse.md +++ b/samples/client/petstore/python/docs/ApiResponse.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **code** | **int** | | [optional] **type** | **str** | | [optional] **message** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md index 6ab77963788..11cd25c98ee 100644 --- a/samples/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_array_number** | **[[float]]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ArrayOfNumberOnly.md b/samples/client/petstore/python/docs/ArrayOfNumberOnly.md index ebc65a54ba7..1e9bb12e4e8 100644 --- a/samples/client/petstore/python/docs/ArrayOfNumberOnly.md +++ b/samples/client/petstore/python/docs/ArrayOfNumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_number** | **[float]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ArrayTest.md b/samples/client/petstore/python/docs/ArrayTest.md index 4e1bda8fc3a..9eac1f8874c 100644 --- a/samples/client/petstore/python/docs/ArrayTest.md +++ b/samples/client/petstore/python/docs/ArrayTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **array_of_string** | **[str]** | | [optional] **array_array_of_integer** | **[[int]]** | | [optional] **array_array_of_model** | [**[[ReadOnlyFirst]]**](ReadOnlyFirst.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Capitalization.md b/samples/client/petstore/python/docs/Capitalization.md index 1ddeadeb3f4..df9989f8db5 100644 --- a/samples/client/petstore/python/docs/Capitalization.md +++ b/samples/client/petstore/python/docs/Capitalization.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **capital_snake** | **str** | | [optional] **sca_eth_flow_points** | **str** | | [optional] **att_name** | **str** | Name of the pet | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Cat.md b/samples/client/petstore/python/docs/Cat.md index e9ce235cd63..082715a2842 100644 --- a/samples/client/petstore/python/docs/Cat.md +++ b/samples/client/petstore/python/docs/Cat.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **class_name** | **str** | | **declawed** | **bool** | | [optional] **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/CatAllOf.md b/samples/client/petstore/python/docs/CatAllOf.md index 0ff7809a99a..6fd1390a749 100644 --- a/samples/client/petstore/python/docs/CatAllOf.md +++ b/samples/client/petstore/python/docs/CatAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **declawed** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Category.md b/samples/client/petstore/python/docs/Category.md index 940f6a45e64..7650eccafba 100644 --- a/samples/client/petstore/python/docs/Category.md +++ b/samples/client/petstore/python/docs/Category.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | defaults to "default-name" **id** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Child.md b/samples/client/petstore/python/docs/Child.md index eb439244571..6bf6903fb20 100644 --- a/samples/client/petstore/python/docs/Child.md +++ b/samples/client/petstore/python/docs/Child.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **radio_waves** | **bool** | | [optional] **tele_vision** | **bool** | | [optional] **inter_net** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildAllOf.md b/samples/client/petstore/python/docs/ChildAllOf.md index f9ae99c7c15..bae8ced9006 100644 --- a/samples/client/petstore/python/docs/ChildAllOf.md +++ b/samples/client/petstore/python/docs/ChildAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **inter_net** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildCat.md b/samples/client/petstore/python/docs/ChildCat.md index 9e3a0fb4b51..513903ac579 100644 --- a/samples/client/petstore/python/docs/ChildCat.md +++ b/samples/client/petstore/python/docs/ChildCat.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | **name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildCatAllOf.md b/samples/client/petstore/python/docs/ChildCatAllOf.md index c5883b9a87c..c5b2f58f28c 100644 --- a/samples/client/petstore/python/docs/ChildCatAllOf.md +++ b/samples/client/petstore/python/docs/ChildCatAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildDog.md b/samples/client/petstore/python/docs/ChildDog.md index 9a6e5b37266..e5b410ce1e7 100644 --- a/samples/client/petstore/python/docs/ChildDog.md +++ b/samples/client/petstore/python/docs/ChildDog.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | **bark** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildDogAllOf.md b/samples/client/petstore/python/docs/ChildDogAllOf.md index 673050667cb..45928c57ef2 100644 --- a/samples/client/petstore/python/docs/ChildDogAllOf.md +++ b/samples/client/petstore/python/docs/ChildDogAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bark** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildLizard.md b/samples/client/petstore/python/docs/ChildLizard.md index e881ee0a1d1..d2e22826e77 100644 --- a/samples/client/petstore/python/docs/ChildLizard.md +++ b/samples/client/petstore/python/docs/ChildLizard.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | **loves_rocks** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ChildLizardAllOf.md b/samples/client/petstore/python/docs/ChildLizardAllOf.md index 6e2b70c0150..6effcfd9313 100644 --- a/samples/client/petstore/python/docs/ChildLizardAllOf.md +++ b/samples/client/petstore/python/docs/ChildLizardAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **loves_rocks** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ClassModel.md b/samples/client/petstore/python/docs/ClassModel.md index 48ed7cbf2ff..6605a16d74a 100644 --- a/samples/client/petstore/python/docs/ClassModel.md +++ b/samples/client/petstore/python/docs/ClassModel.md @@ -6,6 +6,7 @@ Model for testing model with \"_class\" property Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_class** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Client.md b/samples/client/petstore/python/docs/Client.md index c3986008d6c..1b293140f34 100644 --- a/samples/client/petstore/python/docs/Client.md +++ b/samples/client/petstore/python/docs/Client.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **client** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Dog.md b/samples/client/petstore/python/docs/Dog.md index 7065c4c983d..51b5b32bdac 100644 --- a/samples/client/petstore/python/docs/Dog.md +++ b/samples/client/petstore/python/docs/Dog.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **class_name** | **str** | | **breed** | **str** | | [optional] **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/DogAllOf.md b/samples/client/petstore/python/docs/DogAllOf.md index 6382bbd8067..2907a9fd5c4 100644 --- a/samples/client/petstore/python/docs/DogAllOf.md +++ b/samples/client/petstore/python/docs/DogAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **breed** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/EnumArrays.md b/samples/client/petstore/python/docs/EnumArrays.md index 9be5c645a80..ad4e9d2fcb7 100644 --- a/samples/client/petstore/python/docs/EnumArrays.md +++ b/samples/client/petstore/python/docs/EnumArrays.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_symbol** | **str** | | [optional] **array_enum** | **[str]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/EnumClass.md b/samples/client/petstore/python/docs/EnumClass.md index a1f9aae5819..39bb0e1644c 100644 --- a/samples/client/petstore/python/docs/EnumClass.md +++ b/samples/client/petstore/python/docs/EnumClass.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **str** | | defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/EnumTest.md b/samples/client/petstore/python/docs/EnumTest.md index eb884224139..052596bfd04 100644 --- a/samples/client/petstore/python/docs/EnumTest.md +++ b/samples/client/petstore/python/docs/EnumTest.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **enum_integer** | **int** | | [optional] **enum_number** | **float** | | [optional] **string_enum** | [**StringEnum**](StringEnum.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/File.md b/samples/client/petstore/python/docs/File.md index 63b1d1a6518..f84547d1933 100644 --- a/samples/client/petstore/python/docs/File.md +++ b/samples/client/petstore/python/docs/File.md @@ -6,6 +6,7 @@ Must be named `File` for test. Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **source_uri** | **str** | Test capitalization | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/FileSchemaTestClass.md b/samples/client/petstore/python/docs/FileSchemaTestClass.md index caf2440821d..4572aa0905b 100644 --- a/samples/client/petstore/python/docs/FileSchemaTestClass.md +++ b/samples/client/petstore/python/docs/FileSchemaTestClass.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **file** | [**File**](File.md) | | [optional] **files** | [**[File]**](File.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/FormatTest.md b/samples/client/petstore/python/docs/FormatTest.md index aef09bfcc83..dbb4c3e6683 100644 --- a/samples/client/petstore/python/docs/FormatTest.md +++ b/samples/client/petstore/python/docs/FormatTest.md @@ -17,6 +17,7 @@ Name | Type | Description | Notes **binary** | **file_type** | | [optional] **date_time** | **datetime** | | [optional] **uuid** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Grandparent.md b/samples/client/petstore/python/docs/Grandparent.md index b6d80a71945..af143938ab5 100644 --- a/samples/client/petstore/python/docs/Grandparent.md +++ b/samples/client/petstore/python/docs/Grandparent.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **radio_waves** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/GrandparentAnimal.md b/samples/client/petstore/python/docs/GrandparentAnimal.md index 15db0708bb1..a1c34037810 100644 --- a/samples/client/petstore/python/docs/GrandparentAnimal.md +++ b/samples/client/petstore/python/docs/GrandparentAnimal.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/HasOnlyReadOnly.md b/samples/client/petstore/python/docs/HasOnlyReadOnly.md index 0e1334519a8..88bc03d4ff5 100644 --- a/samples/client/petstore/python/docs/HasOnlyReadOnly.md +++ b/samples/client/petstore/python/docs/HasOnlyReadOnly.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **str** | | [optional] [readonly] **foo** | **str** | | [optional] [readonly] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/List.md b/samples/client/petstore/python/docs/List.md index 4b60956971a..13f2694de35 100644 --- a/samples/client/petstore/python/docs/List.md +++ b/samples/client/petstore/python/docs/List.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_123_list** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/MapTest.md b/samples/client/petstore/python/docs/MapTest.md index 15228ee1f28..e6584f3811e 100644 --- a/samples/client/petstore/python/docs/MapTest.md +++ b/samples/client/petstore/python/docs/MapTest.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **map_of_enum_string** | **{str: (str,)}** | | [optional] **direct_map** | **{str: (bool,)}** | | [optional] **indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md index f489944a20a..f32c4e04134 100644 --- a/samples/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **uuid** | **str** | | [optional] **date_time** | **datetime** | | [optional] **map** | [**{str: (Animal,)}**](Animal.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Model200Response.md b/samples/client/petstore/python/docs/Model200Response.md index c958bd4b33f..f7ef7d79acf 100644 --- a/samples/client/petstore/python/docs/Model200Response.md +++ b/samples/client/petstore/python/docs/Model200Response.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | [optional] **_class** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ModelReturn.md b/samples/client/petstore/python/docs/ModelReturn.md index 043e9d466fa..75fb39a8869 100644 --- a/samples/client/petstore/python/docs/ModelReturn.md +++ b/samples/client/petstore/python/docs/ModelReturn.md @@ -6,6 +6,7 @@ Model for testing reserved words Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_return** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Name.md b/samples/client/petstore/python/docs/Name.md index 3be719cdbfb..6e58fae6d0b 100644 --- a/samples/client/petstore/python/docs/Name.md +++ b/samples/client/petstore/python/docs/Name.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **snake_case** | **int** | | [optional] [readonly] **_property** | **str** | | [optional] **_123_number** | **int** | | [optional] [readonly] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/NumberOnly.md b/samples/client/petstore/python/docs/NumberOnly.md index 37195c5d899..172e86163a4 100644 --- a/samples/client/petstore/python/docs/NumberOnly.md +++ b/samples/client/petstore/python/docs/NumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_number** | **float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/NumberWithValidations.md b/samples/client/petstore/python/docs/NumberWithValidations.md index 119e0f67823..cc6f77c152c 100644 --- a/samples/client/petstore/python/docs/NumberWithValidations.md +++ b/samples/client/petstore/python/docs/NumberWithValidations.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **float** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ObjectModelWithRefProps.md b/samples/client/petstore/python/docs/ObjectModelWithRefProps.md index 5ff4e52033d..a0d15f4bbd1 100644 --- a/samples/client/petstore/python/docs/ObjectModelWithRefProps.md +++ b/samples/client/petstore/python/docs/ObjectModelWithRefProps.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **my_number** | [**NumberWithValidations**](NumberWithValidations.md) | | [optional] **my_string** | **str** | | [optional] **my_boolean** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Order.md b/samples/client/petstore/python/docs/Order.md index d29e1a381de..0423082932d 100644 --- a/samples/client/petstore/python/docs/Order.md +++ b/samples/client/petstore/python/docs/Order.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **ship_date** | **datetime** | | [optional] **status** | **str** | Order Status | [optional] **complete** | **bool** | | [optional] if omitted the server will use the default value of False +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Parent.md b/samples/client/petstore/python/docs/Parent.md index 9d3f02d68b3..9db770844ee 100644 --- a/samples/client/petstore/python/docs/Parent.md +++ b/samples/client/petstore/python/docs/Parent.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **radio_waves** | **bool** | | [optional] **tele_vision** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ParentAllOf.md b/samples/client/petstore/python/docs/ParentAllOf.md index 569a5e4af14..84ac2c066ee 100644 --- a/samples/client/petstore/python/docs/ParentAllOf.md +++ b/samples/client/petstore/python/docs/ParentAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **tele_vision** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ParentPet.md b/samples/client/petstore/python/docs/ParentPet.md index 09e409c8fcf..111ada88b3d 100644 --- a/samples/client/petstore/python/docs/ParentPet.md +++ b/samples/client/petstore/python/docs/ParentPet.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Pet.md b/samples/client/petstore/python/docs/Pet.md index 6e78495272e..e0b12978456 100644 --- a/samples/client/petstore/python/docs/Pet.md +++ b/samples/client/petstore/python/docs/Pet.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **category** | [**Category**](Category.md) | | [optional] **tags** | [**[Tag]**](Tag.md) | | [optional] **status** | **str** | pet status in the store | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Player.md b/samples/client/petstore/python/docs/Player.md index 2014198aa1b..97441ae316b 100644 --- a/samples/client/petstore/python/docs/Player.md +++ b/samples/client/petstore/python/docs/Player.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | **enemy_player** | [**Player**](Player.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/ReadOnlyFirst.md b/samples/client/petstore/python/docs/ReadOnlyFirst.md index 53b4c61d844..ba39ec3d04e 100644 --- a/samples/client/petstore/python/docs/ReadOnlyFirst.md +++ b/samples/client/petstore/python/docs/ReadOnlyFirst.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **str** | | [optional] [readonly] **baz** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/SpecialModelName.md b/samples/client/petstore/python/docs/SpecialModelName.md index 268e1134192..4a1c86ff4de 100644 --- a/samples/client/petstore/python/docs/SpecialModelName.md +++ b/samples/client/petstore/python/docs/SpecialModelName.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **special_property_name** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/StringEnum.md b/samples/client/petstore/python/docs/StringEnum.md index bb195ec0e45..1ac6df2fb79 100644 --- a/samples/client/petstore/python/docs/StringEnum.md +++ b/samples/client/petstore/python/docs/StringEnum.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **str** | | must be one of ["placed", "approved", "delivered", ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Tag.md b/samples/client/petstore/python/docs/Tag.md index b9fe1e0944c..bfe06d1c5bf 100644 --- a/samples/client/petstore/python/docs/Tag.md +++ b/samples/client/petstore/python/docs/Tag.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **id** | **int** | | [optional] **name** | **str** | | [optional] **full_name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/TypeHolderDefault.md b/samples/client/petstore/python/docs/TypeHolderDefault.md index 904915aec01..f15c61cc461 100644 --- a/samples/client/petstore/python/docs/TypeHolderDefault.md +++ b/samples/client/petstore/python/docs/TypeHolderDefault.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **bool_item** | **bool** | | defaults to True **date_item** | **date** | | [optional] **datetime_item** | **datetime** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/TypeHolderExample.md b/samples/client/petstore/python/docs/TypeHolderExample.md index d2954c64dce..d707ca3af20 100644 --- a/samples/client/petstore/python/docs/TypeHolderExample.md +++ b/samples/client/petstore/python/docs/TypeHolderExample.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **string_item** | **str** | | defaults to "what" **number_item** | **float** | | defaults to 1.234 **integer_item** | **int** | | defaults to -2 +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/User.md b/samples/client/petstore/python/docs/User.md index b0079f591b6..8e677b63cca 100644 --- a/samples/client/petstore/python/docs/User.md +++ b/samples/client/petstore/python/docs/User.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **password** | **str** | | [optional] **phone** | **str** | | [optional] **user_status** | **int** | User Status | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/XmlItem.md b/samples/client/petstore/python/docs/XmlItem.md index ea3d7f92804..9852234a736 100644 --- a/samples/client/petstore/python/docs/XmlItem.md +++ b/samples/client/petstore/python/docs/XmlItem.md @@ -33,6 +33,7 @@ Name | Type | Description | Notes **prefix_ns_boolean** | **bool** | | [optional] **prefix_ns_array** | **[int]** | | [optional] **prefix_ns_wrapped_array** | **[int]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/petstore_api/model/additional_properties_any_type.py b/samples/client/petstore/python/petstore_api/model/additional_properties_any_type.py index 4531d8f2d86..7239795cf4a 100644 --- a/samples/client/petstore/python/petstore_api/model/additional_properties_any_type.py +++ b/samples/client/petstore/python/petstore_api/model/additional_properties_any_type.py @@ -63,7 +63,7 @@ class AdditionalPropertiesAnyType(ModelNormal): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return (bool, date, datetime, dict, float, int, list, str,) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/additional_properties_array.py b/samples/client/petstore/python/petstore_api/model/additional_properties_array.py index 4a35500c63f..7d9403758a0 100644 --- a/samples/client/petstore/python/petstore_api/model/additional_properties_array.py +++ b/samples/client/petstore/python/petstore_api/model/additional_properties_array.py @@ -63,7 +63,7 @@ class AdditionalPropertiesArray(ModelNormal): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ([bool, date, datetime, dict, float, int, list, str],) # noqa: E501 + return ([bool, date, datetime, dict, float, int, list, str, none_type],) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/additional_properties_class.py b/samples/client/petstore/python/petstore_api/model/additional_properties_class.py index 743f3be54d4..39719e00dcf 100644 --- a/samples/client/petstore/python/petstore_api/model/additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/model/additional_properties_class.py @@ -57,7 +57,13 @@ class AdditionalPropertiesClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -77,12 +83,12 @@ class AdditionalPropertiesClass(ModelNormal): 'map_integer': ({str: (int,)},), # noqa: E501 'map_boolean': ({str: (bool,)},), # noqa: E501 'map_array_integer': ({str: ([int],)},), # noqa: E501 - 'map_array_anytype': ({str: ([bool, date, datetime, dict, float, int, list, str],)},), # noqa: E501 + 'map_array_anytype': ({str: ([bool, date, datetime, dict, float, int, list, str, none_type],)},), # noqa: E501 'map_map_string': ({str: ({str: (str,)},)},), # noqa: E501 - 'map_map_anytype': ({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)},), # noqa: E501 - 'anytype_1': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501 - 'anytype_2': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501 - 'anytype_3': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501 + 'map_map_anytype': ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)},), # noqa: E501 + 'anytype_1': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 + 'anytype_2': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 + 'anytype_3': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 } @cached_property @@ -155,12 +161,12 @@ class AdditionalPropertiesClass(ModelNormal): map_integer ({str: (int,)}): [optional] # noqa: E501 map_boolean ({str: (bool,)}): [optional] # noqa: E501 map_array_integer ({str: ([int],)}): [optional] # noqa: E501 - map_array_anytype ({str: ([bool, date, datetime, dict, float, int, list, str],)}): [optional] # noqa: E501 + map_array_anytype ({str: ([bool, date, datetime, dict, float, int, list, str, none_type],)}): [optional] # noqa: E501 map_map_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 - map_map_anytype ({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}): [optional] # noqa: E501 - anytype_1 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501 - anytype_2 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501 - anytype_3 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501 + map_map_anytype ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)}): [optional] # noqa: E501 + anytype_1 (bool, date, datetime, dict, float, int, list, str, none_type): [optional] # noqa: E501 + anytype_2 (bool, date, datetime, dict, float, int, list, str, none_type): no type is set for this. [optional] # noqa: E501 + anytype_3 (bool, date, datetime, dict, float, int, list, str, none_type): because of a bug in swagger-parser, this should have values {str: (str, int, float...)} but instead we get any type. See https://github.com/swagger-api/swagger-parser/issues/1378. [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/client/petstore/python/petstore_api/model/additional_properties_object.py b/samples/client/petstore/python/petstore_api/model/additional_properties_object.py index 40e80e16044..000653f13a7 100644 --- a/samples/client/petstore/python/petstore_api/model/additional_properties_object.py +++ b/samples/client/petstore/python/petstore_api/model/additional_properties_object.py @@ -63,7 +63,7 @@ class AdditionalPropertiesObject(ModelNormal): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ({str: (bool, date, datetime, dict, float, int, list, str,)},) # noqa: E501 + return ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/animal.py b/samples/client/petstore/python/petstore_api/model/animal.py index a3d48b6ea97..c53b1e1ad28 100644 --- a/samples/client/petstore/python/petstore_api/model/animal.py +++ b/samples/client/petstore/python/petstore_api/model/animal.py @@ -63,7 +63,14 @@ class Animal(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/animal_farm.py b/samples/client/petstore/python/petstore_api/model/animal_farm.py index 838b18a1297..fb58224ebd4 100644 --- a/samples/client/petstore/python/petstore_api/model/animal_farm.py +++ b/samples/client/petstore/python/petstore_api/model/animal_farm.py @@ -57,7 +57,14 @@ class AnimalFarm(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/api_response.py b/samples/client/petstore/python/petstore_api/model/api_response.py index 01e2175b800..53adb5aba12 100644 --- a/samples/client/petstore/python/petstore_api/model/api_response.py +++ b/samples/client/petstore/python/petstore_api/model/api_response.py @@ -57,7 +57,13 @@ class ApiResponse(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py b/samples/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py index 008b74dd42a..8b6a2c42d0e 100644 --- a/samples/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py @@ -57,7 +57,13 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/array_of_number_only.py b/samples/client/petstore/python/petstore_api/model/array_of_number_only.py index f2e080bc258..7b754dc283e 100644 --- a/samples/client/petstore/python/petstore_api/model/array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/model/array_of_number_only.py @@ -57,7 +57,13 @@ class ArrayOfNumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/array_test.py b/samples/client/petstore/python/petstore_api/model/array_test.py index ac42b07b93c..9691a1e6037 100644 --- a/samples/client/petstore/python/petstore_api/model/array_test.py +++ b/samples/client/petstore/python/petstore_api/model/array_test.py @@ -61,7 +61,14 @@ class ArrayTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/capitalization.py b/samples/client/petstore/python/petstore_api/model/capitalization.py index 710c17e51a5..6d939535cee 100644 --- a/samples/client/petstore/python/petstore_api/model/capitalization.py +++ b/samples/client/petstore/python/petstore_api/model/capitalization.py @@ -57,7 +57,13 @@ class Capitalization(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/cat.py b/samples/client/petstore/python/petstore_api/model/cat.py index 8b5c46413b9..eeea79359fc 100644 --- a/samples/client/petstore/python/petstore_api/model/cat.py +++ b/samples/client/petstore/python/petstore_api/model/cat.py @@ -63,7 +63,14 @@ class Cat(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -111,13 +118,11 @@ class Cat(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Cat - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -182,26 +187,18 @@ class Cat(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/cat_all_of.py b/samples/client/petstore/python/petstore_api/model/cat_all_of.py index 50b046510df..7efba680b4d 100644 --- a/samples/client/petstore/python/petstore_api/model/cat_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/cat_all_of.py @@ -57,7 +57,13 @@ class CatAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/category.py b/samples/client/petstore/python/petstore_api/model/category.py index ed167471d35..4936b4f0e44 100644 --- a/samples/client/petstore/python/petstore_api/model/category.py +++ b/samples/client/petstore/python/petstore_api/model/category.py @@ -57,7 +57,13 @@ class Category(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/child.py b/samples/client/petstore/python/petstore_api/model/child.py index c8f0a70a193..8fad3bf107b 100644 --- a/samples/client/petstore/python/petstore_api/model/child.py +++ b/samples/client/petstore/python/petstore_api/model/child.py @@ -63,7 +63,14 @@ class Child(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -177,25 +184,18 @@ class Child(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/child_all_of.py b/samples/client/petstore/python/petstore_api/model/child_all_of.py index 2339e520bd6..9db852ec725 100644 --- a/samples/client/petstore/python/petstore_api/model/child_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/child_all_of.py @@ -57,7 +57,13 @@ class ChildAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/child_cat.py b/samples/client/petstore/python/petstore_api/model/child_cat.py index a7d52b48e8a..d054cb7a97a 100644 --- a/samples/client/petstore/python/petstore_api/model/child_cat.py +++ b/samples/client/petstore/python/petstore_api/model/child_cat.py @@ -63,7 +63,14 @@ class ChildCat(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -109,13 +116,11 @@ class ChildCat(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ChildCat - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -179,26 +184,18 @@ class ChildCat(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/child_cat_all_of.py b/samples/client/petstore/python/petstore_api/model/child_cat_all_of.py index f0f1a1ae6bd..3d732d085fb 100644 --- a/samples/client/petstore/python/petstore_api/model/child_cat_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/child_cat_all_of.py @@ -57,7 +57,13 @@ class ChildCatAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/child_dog.py b/samples/client/petstore/python/petstore_api/model/child_dog.py index 2bc0882ac2a..6244359fea2 100644 --- a/samples/client/petstore/python/petstore_api/model/child_dog.py +++ b/samples/client/petstore/python/petstore_api/model/child_dog.py @@ -63,7 +63,14 @@ class ChildDog(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -109,13 +116,11 @@ class ChildDog(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ChildDog - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -179,26 +184,18 @@ class ChildDog(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/child_dog_all_of.py b/samples/client/petstore/python/petstore_api/model/child_dog_all_of.py index d460b68b3d3..d3a0d89c4da 100644 --- a/samples/client/petstore/python/petstore_api/model/child_dog_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/child_dog_all_of.py @@ -57,7 +57,13 @@ class ChildDogAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/child_lizard.py b/samples/client/petstore/python/petstore_api/model/child_lizard.py index 6142b9c751f..b56925a0c92 100644 --- a/samples/client/petstore/python/petstore_api/model/child_lizard.py +++ b/samples/client/petstore/python/petstore_api/model/child_lizard.py @@ -63,7 +63,14 @@ class ChildLizard(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -109,13 +116,11 @@ class ChildLizard(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ChildLizard - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -179,26 +184,18 @@ class ChildLizard(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/child_lizard_all_of.py b/samples/client/petstore/python/petstore_api/model/child_lizard_all_of.py index 669b9338d79..1c8f29548b5 100644 --- a/samples/client/petstore/python/petstore_api/model/child_lizard_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/child_lizard_all_of.py @@ -57,7 +57,13 @@ class ChildLizardAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/class_model.py b/samples/client/petstore/python/petstore_api/model/class_model.py index 18c16f89f90..9e65a937365 100644 --- a/samples/client/petstore/python/petstore_api/model/class_model.py +++ b/samples/client/petstore/python/petstore_api/model/class_model.py @@ -57,7 +57,13 @@ class ClassModel(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/client.py b/samples/client/petstore/python/petstore_api/model/client.py index da615c54773..6218de1e19e 100644 --- a/samples/client/petstore/python/petstore_api/model/client.py +++ b/samples/client/petstore/python/petstore_api/model/client.py @@ -57,7 +57,13 @@ class Client(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/dog.py b/samples/client/petstore/python/petstore_api/model/dog.py index e9c201c983b..3452f0d040a 100644 --- a/samples/client/petstore/python/petstore_api/model/dog.py +++ b/samples/client/petstore/python/petstore_api/model/dog.py @@ -63,7 +63,14 @@ class Dog(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -111,13 +118,11 @@ class Dog(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Dog - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -182,26 +187,18 @@ class Dog(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/dog_all_of.py b/samples/client/petstore/python/petstore_api/model/dog_all_of.py index b7b2e7db66d..962903d3a38 100644 --- a/samples/client/petstore/python/petstore_api/model/dog_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/dog_all_of.py @@ -57,7 +57,13 @@ class DogAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/enum_arrays.py b/samples/client/petstore/python/petstore_api/model/enum_arrays.py index 43ebac57de3..db56838d7e4 100644 --- a/samples/client/petstore/python/petstore_api/model/enum_arrays.py +++ b/samples/client/petstore/python/petstore_api/model/enum_arrays.py @@ -65,7 +65,13 @@ class EnumArrays(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/enum_class.py b/samples/client/petstore/python/petstore_api/model/enum_class.py index 14188ca31d2..63be703c38e 100644 --- a/samples/client/petstore/python/petstore_api/model/enum_class.py +++ b/samples/client/petstore/python/petstore_api/model/enum_class.py @@ -58,7 +58,13 @@ class EnumClass(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/enum_test.py b/samples/client/petstore/python/petstore_api/model/enum_test.py index 79ba0f6a747..ee14c70b46f 100644 --- a/samples/client/petstore/python/petstore_api/model/enum_test.py +++ b/samples/client/petstore/python/petstore_api/model/enum_test.py @@ -79,7 +79,14 @@ class EnumTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/file.py b/samples/client/petstore/python/petstore_api/model/file.py index a38cccacc6a..137d0026324 100644 --- a/samples/client/petstore/python/petstore_api/model/file.py +++ b/samples/client/petstore/python/petstore_api/model/file.py @@ -57,7 +57,13 @@ class File(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/file_schema_test_class.py b/samples/client/petstore/python/petstore_api/model/file_schema_test_class.py index b8c519ed9c7..3722125ae48 100644 --- a/samples/client/petstore/python/petstore_api/model/file_schema_test_class.py +++ b/samples/client/petstore/python/petstore_api/model/file_schema_test_class.py @@ -61,7 +61,14 @@ class FileSchemaTestClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/format_test.py b/samples/client/petstore/python/petstore_api/model/format_test.py index 494ce2646da..7b415af7ad2 100644 --- a/samples/client/petstore/python/petstore_api/model/format_test.py +++ b/samples/client/petstore/python/petstore_api/model/format_test.py @@ -92,7 +92,13 @@ class FormatTest(ModelNormal): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/grandparent.py b/samples/client/petstore/python/petstore_api/model/grandparent.py index a52744cc3e2..728b1e1d129 100644 --- a/samples/client/petstore/python/petstore_api/model/grandparent.py +++ b/samples/client/petstore/python/petstore_api/model/grandparent.py @@ -57,7 +57,13 @@ class Grandparent(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/grandparent_animal.py b/samples/client/petstore/python/petstore_api/model/grandparent_animal.py index 48d3f6d9f0b..089f5a4a07c 100644 --- a/samples/client/petstore/python/petstore_api/model/grandparent_animal.py +++ b/samples/client/petstore/python/petstore_api/model/grandparent_animal.py @@ -67,7 +67,14 @@ class GrandparentAnimal(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/has_only_read_only.py b/samples/client/petstore/python/petstore_api/model/has_only_read_only.py index c94781ae2c4..4ea0bb08721 100644 --- a/samples/client/petstore/python/petstore_api/model/has_only_read_only.py +++ b/samples/client/petstore/python/petstore_api/model/has_only_read_only.py @@ -57,7 +57,13 @@ class HasOnlyReadOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/list.py b/samples/client/petstore/python/petstore_api/model/list.py index 09c762d6a79..11b46f10b56 100644 --- a/samples/client/petstore/python/petstore_api/model/list.py +++ b/samples/client/petstore/python/petstore_api/model/list.py @@ -57,7 +57,13 @@ class List(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/map_test.py b/samples/client/petstore/python/petstore_api/model/map_test.py index 169fb9d88ee..a5418b39e73 100644 --- a/samples/client/petstore/python/petstore_api/model/map_test.py +++ b/samples/client/petstore/python/petstore_api/model/map_test.py @@ -65,7 +65,14 @@ class MapTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py index 01df80d9d62..67b3f79d9e5 100644 --- a/samples/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py @@ -61,7 +61,14 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/model200_response.py b/samples/client/petstore/python/petstore_api/model/model200_response.py index 46b155b6523..056f4c56ad3 100644 --- a/samples/client/petstore/python/petstore_api/model/model200_response.py +++ b/samples/client/petstore/python/petstore_api/model/model200_response.py @@ -57,7 +57,13 @@ class Model200Response(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/model_return.py b/samples/client/petstore/python/petstore_api/model/model_return.py index 377b3507a8b..5f34582cdb4 100644 --- a/samples/client/petstore/python/petstore_api/model/model_return.py +++ b/samples/client/petstore/python/petstore_api/model/model_return.py @@ -57,7 +57,13 @@ class ModelReturn(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/name.py b/samples/client/petstore/python/petstore_api/model/name.py index 1432e185ad6..06b387ce9bf 100644 --- a/samples/client/petstore/python/petstore_api/model/name.py +++ b/samples/client/petstore/python/petstore_api/model/name.py @@ -57,7 +57,13 @@ class Name(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/number_only.py b/samples/client/petstore/python/petstore_api/model/number_only.py index d4892dbede5..cb2c9e2ad52 100644 --- a/samples/client/petstore/python/petstore_api/model/number_only.py +++ b/samples/client/petstore/python/petstore_api/model/number_only.py @@ -57,7 +57,13 @@ class NumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/number_with_validations.py b/samples/client/petstore/python/petstore_api/model/number_with_validations.py index 458a7945975..fb47d885bfd 100644 --- a/samples/client/petstore/python/petstore_api/model/number_with_validations.py +++ b/samples/client/petstore/python/petstore_api/model/number_with_validations.py @@ -57,7 +57,13 @@ class NumberWithValidations(ModelSimple): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/object_model_with_ref_props.py b/samples/client/petstore/python/petstore_api/model/object_model_with_ref_props.py index b1dc4bf82e2..7256f67a8d6 100644 --- a/samples/client/petstore/python/petstore_api/model/object_model_with_ref_props.py +++ b/samples/client/petstore/python/petstore_api/model/object_model_with_ref_props.py @@ -61,7 +61,14 @@ class ObjectModelWithRefProps(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/order.py b/samples/client/petstore/python/petstore_api/model/order.py index b42f066848a..48207e4560e 100644 --- a/samples/client/petstore/python/petstore_api/model/order.py +++ b/samples/client/petstore/python/petstore_api/model/order.py @@ -62,7 +62,13 @@ class Order(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/parent.py b/samples/client/petstore/python/petstore_api/model/parent.py index a5e5d878d84..063d5051747 100644 --- a/samples/client/petstore/python/petstore_api/model/parent.py +++ b/samples/client/petstore/python/petstore_api/model/parent.py @@ -63,7 +63,14 @@ class Parent(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -174,25 +181,18 @@ class Parent(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/parent_all_of.py b/samples/client/petstore/python/petstore_api/model/parent_all_of.py index 0d109f25a4c..2f7b8a791d2 100644 --- a/samples/client/petstore/python/petstore_api/model/parent_all_of.py +++ b/samples/client/petstore/python/petstore_api/model/parent_all_of.py @@ -57,7 +57,13 @@ class ParentAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/parent_pet.py b/samples/client/petstore/python/petstore_api/model/parent_pet.py index aac0ff12e86..b012d1558a7 100644 --- a/samples/client/petstore/python/petstore_api/model/parent_pet.py +++ b/samples/client/petstore/python/petstore_api/model/parent_pet.py @@ -67,7 +67,14 @@ class ParentPet(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -115,13 +122,11 @@ class ParentPet(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ParentPet - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -184,26 +189,18 @@ class ParentPet(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python/petstore_api/model/pet.py b/samples/client/petstore/python/petstore_api/model/pet.py index e9f1e30a319..b0c8b08607d 100644 --- a/samples/client/petstore/python/petstore_api/model/pet.py +++ b/samples/client/petstore/python/petstore_api/model/pet.py @@ -68,7 +68,14 @@ class Pet(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/player.py b/samples/client/petstore/python/petstore_api/model/player.py index 6e4485fb650..2c51f9b57af 100644 --- a/samples/client/petstore/python/petstore_api/model/player.py +++ b/samples/client/petstore/python/petstore_api/model/player.py @@ -57,7 +57,13 @@ class Player(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/read_only_first.py b/samples/client/petstore/python/petstore_api/model/read_only_first.py index 5c68eab91ea..0302bf96a7e 100644 --- a/samples/client/petstore/python/petstore_api/model/read_only_first.py +++ b/samples/client/petstore/python/petstore_api/model/read_only_first.py @@ -57,7 +57,13 @@ class ReadOnlyFirst(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/special_model_name.py b/samples/client/petstore/python/petstore_api/model/special_model_name.py index 823e7759663..cfaedbc7881 100644 --- a/samples/client/petstore/python/petstore_api/model/special_model_name.py +++ b/samples/client/petstore/python/petstore_api/model/special_model_name.py @@ -57,7 +57,13 @@ class SpecialModelName(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/string_enum.py b/samples/client/petstore/python/petstore_api/model/string_enum.py index 37dc04332ca..4c92316cb7e 100644 --- a/samples/client/petstore/python/petstore_api/model/string_enum.py +++ b/samples/client/petstore/python/petstore_api/model/string_enum.py @@ -58,7 +58,13 @@ class StringEnum(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/tag.py b/samples/client/petstore/python/petstore_api/model/tag.py index d3dcb78b7ea..01c28233598 100644 --- a/samples/client/petstore/python/petstore_api/model/tag.py +++ b/samples/client/petstore/python/petstore_api/model/tag.py @@ -57,7 +57,13 @@ class Tag(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/type_holder_default.py b/samples/client/petstore/python/petstore_api/model/type_holder_default.py index 324b131f3a2..04a96f7e906 100644 --- a/samples/client/petstore/python/petstore_api/model/type_holder_default.py +++ b/samples/client/petstore/python/petstore_api/model/type_holder_default.py @@ -57,7 +57,13 @@ class TypeHolderDefault(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/type_holder_example.py b/samples/client/petstore/python/petstore_api/model/type_holder_example.py index 30bbba178f4..f6e5f44c389 100644 --- a/samples/client/petstore/python/petstore_api/model/type_holder_example.py +++ b/samples/client/petstore/python/petstore_api/model/type_holder_example.py @@ -66,7 +66,13 @@ class TypeHolderExample(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/user.py b/samples/client/petstore/python/petstore_api/model/user.py index 9a3cd081411..64bd6984933 100644 --- a/samples/client/petstore/python/petstore_api/model/user.py +++ b/samples/client/petstore/python/petstore_api/model/user.py @@ -57,7 +57,13 @@ class User(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model/xml_item.py b/samples/client/petstore/python/petstore_api/model/xml_item.py index 8401b3f4007..ba096779721 100644 --- a/samples/client/petstore/python/petstore_api/model/xml_item.py +++ b/samples/client/petstore/python/petstore_api/model/xml_item.py @@ -57,7 +57,13 @@ class XmlItem(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/client/petstore/python/petstore_api/model_utils.py b/samples/client/petstore/python/petstore_api/model_utils.py index ae554710670..b6d5934170a 100644 --- a/samples/client/petstore/python/petstore_api/model_utils.py +++ b/samples/client/petstore/python/petstore_api/model_utils.py @@ -434,27 +434,43 @@ class ModelComposed(OpenApiModel): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -464,13 +480,12 @@ class ModelComposed(OpenApiModel): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1573,8 +1588,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1582,20 +1602,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1655,31 +1663,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1736,24 +1722,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1766,47 +1736,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1850,36 +1807,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] diff --git a/samples/client/petstore/python/pom.xml b/samples/client/petstore/python/pom.xml index 9dc399cc808..f6178c5c09c 100644 --- a/samples/client/petstore/python/pom.xml +++ b/samples/client/petstore/python/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.openapitools - PythonExperimentalPetstoreClientTests + PythonV2PetstoreClientTestsWithComposition pom 1.0-SNAPSHOT - Python Experimental OpenAPI Petstore Client + Python OpenAPI Petstore Client diff --git a/samples/client/petstore/python/test/test_child.py b/samples/client/petstore/python/test/test_child.py index 3b49febd953..88e6b9ed4a8 100644 --- a/samples/client/petstore/python/test/test_child.py +++ b/samples/client/petstore/python/test/test_child.py @@ -73,14 +73,6 @@ class TestChild(unittest.TestCase): } ) - # setting a value that doesn't exist raises an exception - # with a key - with self.assertRaises(petstore_api.ApiAttributeError): - child['invalid_variable'] = 'some value' - # with setattr - with self.assertRaises(petstore_api.ApiAttributeError): - setattr(child, 'invalid_variable', 'some value') - # with hasattr self.assertFalse(hasattr(child, 'invalid_variable')) @@ -123,17 +115,26 @@ class TestChild(unittest.TestCase): self.assertEqual( child._var_name_to_model_instances, { - 'radio_waves': [child, parent_instance], - 'tele_vision': [child, parent_instance], - 'inter_net': [child, child_allof_instance] + 'radio_waves': [child, child_allof_instance, parent_instance], + 'tele_vision': [child, child_allof_instance, parent_instance], + 'inter_net': [child, child_allof_instance, parent_instance] } ) # model._additional_properties_model_instances stores a list of # models which have the property additional_properties_type != None self.assertEqual( - child._additional_properties_model_instances, [] + child._additional_properties_model_instances, [child] ) + # setting a value that doesn't exist works + # with a key + child['invalid_variable'] = 'a' + assert child.invalid_variable == 'a' + # with setattr + setattr(child, 'invalid_variable', 'b') + assert child.invalid_variable == 'b' + + # if we modify one of the properties owned by multiple # model_instances we get an exception when we try to access that # property because the retrieved values are not all the same @@ -141,13 +142,13 @@ class TestChild(unittest.TestCase): with self.assertRaises(petstore_api.ApiValueError): inter_net = child.inter_net - # including extra parameters raises an exception - with self.assertRaises(petstore_api.ApiValueError): - child = Child( - radio_waves=radio_waves, - tele_vision=tele_vision, - inter_net=inter_net, - unknown_property='some value') + # including extra parameters works + child = Child( + radio_waves=radio_waves, + tele_vision=tele_vision, + inter_net=inter_net, + unknown_property='some value') + assert child.unknown_property == 'some value' if __name__ == '__main__': unittest.main() diff --git a/samples/client/petstore/python/test/test_dog.py b/samples/client/petstore/python/test/test_dog.py index 0b95c0a4c83..0352d794c92 100644 --- a/samples/client/petstore/python/test/test_dog.py +++ b/samples/client/petstore/python/test/test_dog.py @@ -73,23 +73,15 @@ class TestDog(unittest.TestCase): } ) - # setting a value that doesn't exist raises an exception - # with a key - with self.assertRaises(AttributeError): - dog['invalid_variable'] = 'some value' - # with setattr - with self.assertRaises(AttributeError): - setattr(dog, 'invalid_variable', 'some value') - # getting a value that doesn't exist raises an exception # with a key with self.assertRaises(AttributeError): - invalid_variable = dog['invalid_variable'] + invalid_variable = dog['not_here_a'] # with getattr - self.assertEqual(getattr(dog, 'invalid_variable', 'some value'), 'some value') + self.assertEqual(getattr(dog, 'not_here_a', 'some value'), 'some value') with self.assertRaises(AttributeError): - invalid_variable = getattr(dog, 'invalid_variable') + invalid_variable = getattr(dog, 'not_here_a') # make sure that the ModelComposed class properties are correct # model.composed_schemas() stores the anyOf/allOf/oneOf info @@ -120,17 +112,25 @@ class TestDog(unittest.TestCase): self.assertEqual( dog._var_name_to_model_instances, { - 'breed': [dog, dog_allof_instance], - 'class_name': [dog, animal_instance], - 'color': [dog, animal_instance] + 'breed': [dog, animal_instance, dog_allof_instance], + 'class_name': [dog, animal_instance, dog_allof_instance], + 'color': [dog, animal_instance, dog_allof_instance] } ) # model._additional_properties_model_instances stores a list of # models which have the property additional_properties_type != None self.assertEqual( - dog._additional_properties_model_instances, [] + dog._additional_properties_model_instances, [dog] ) + # setting a value that doesn't exist works + dog['invalid_variable'] = 'a' + assert dog.invalid_variable == 'a' + + # with setattr + setattr(dog, 'invalid_variable', 'b') + assert dog.invalid_variable == 'b' + # if we modify one of the properties owned by multiple # model_instances we get an exception when we try to access that # property because the retrieved values are not all the same @@ -138,14 +138,14 @@ class TestDog(unittest.TestCase): with self.assertRaises(petstore_api.ApiValueError): breed = dog.breed - # including extra parameters raises an exception - with self.assertRaises(petstore_api.ApiValueError): - dog = Dog( - class_name=class_name, - color=color, - breed=breed, - unknown_property='some value' - ) + # including extra parameters works + dog = Dog( + class_name=class_name, + color=color, + breed=breed, + unknown_property='some value' + ) + assert dog.unknown_property == 'some value' if __name__ == '__main__': unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitignore b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitignore new file mode 100644 index 00000000000..43995bd42fa --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitignore @@ -0,0 +1,66 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitlab-ci.yml b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitlab-ci.yml new file mode 100644 index 00000000000..9e84f517616 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.gitlab-ci.yml @@ -0,0 +1,24 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.tests: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=petstore_api + +test-3.6: + extends: .tests + image: python:3.6-alpine +test-3.7: + extends: .tests + image: python:3.7-alpine +test-3.8: + extends: .tests + image: python:3.8-alpine +test-3.9: + extends: .tests + image: python:3.9-alpine diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator-ignore b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES new file mode 100644 index 00000000000..94732e37243 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES @@ -0,0 +1,160 @@ +.gitignore +.gitlab-ci.yml +.travis.yml +README.md +docs/AdditionalPropertiesAnyType.md +docs/AdditionalPropertiesArray.md +docs/AdditionalPropertiesBoolean.md +docs/AdditionalPropertiesClass.md +docs/AdditionalPropertiesInteger.md +docs/AdditionalPropertiesNumber.md +docs/AdditionalPropertiesObject.md +docs/AdditionalPropertiesString.md +docs/Animal.md +docs/AnimalFarm.md +docs/AnotherFakeApi.md +docs/ApiResponse.md +docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfNumberOnly.md +docs/ArrayTest.md +docs/Capitalization.md +docs/Cat.md +docs/CatAllOf.md +docs/Category.md +docs/Child.md +docs/ChildAllOf.md +docs/ChildCat.md +docs/ChildCatAllOf.md +docs/ChildDog.md +docs/ChildDogAllOf.md +docs/ChildLizard.md +docs/ChildLizardAllOf.md +docs/ClassModel.md +docs/Client.md +docs/Dog.md +docs/DogAllOf.md +docs/EnumArrays.md +docs/EnumClass.md +docs/EnumTest.md +docs/FakeApi.md +docs/FakeClassnameTags123Api.md +docs/File.md +docs/FileSchemaTestClass.md +docs/FormatTest.md +docs/Grandparent.md +docs/GrandparentAnimal.md +docs/HasOnlyReadOnly.md +docs/List.md +docs/MapTest.md +docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/Model200Response.md +docs/ModelReturn.md +docs/Name.md +docs/NumberOnly.md +docs/NumberWithValidations.md +docs/ObjectModelWithRefProps.md +docs/Order.md +docs/Parent.md +docs/ParentAllOf.md +docs/ParentPet.md +docs/Pet.md +docs/PetApi.md +docs/Player.md +docs/ReadOnlyFirst.md +docs/SpecialModelName.md +docs/StoreApi.md +docs/StringBooleanMap.md +docs/StringEnum.md +docs/Tag.md +docs/TypeHolderDefault.md +docs/TypeHolderExample.md +docs/User.md +docs/UserApi.md +docs/XmlItem.md +git_push.sh +petstore_api/__init__.py +petstore_api/api/__init__.py +petstore_api/api/another_fake_api.py +petstore_api/api/fake_api.py +petstore_api/api/fake_classname_tags_123_api.py +petstore_api/api/pet_api.py +petstore_api/api/store_api.py +petstore_api/api/user_api.py +petstore_api/api_client.py +petstore_api/apis/__init__.py +petstore_api/configuration.py +petstore_api/exceptions.py +petstore_api/model/__init__.py +petstore_api/model/additional_properties_any_type.py +petstore_api/model/additional_properties_array.py +petstore_api/model/additional_properties_boolean.py +petstore_api/model/additional_properties_class.py +petstore_api/model/additional_properties_integer.py +petstore_api/model/additional_properties_number.py +petstore_api/model/additional_properties_object.py +petstore_api/model/additional_properties_string.py +petstore_api/model/animal.py +petstore_api/model/animal_farm.py +petstore_api/model/api_response.py +petstore_api/model/array_of_array_of_number_only.py +petstore_api/model/array_of_number_only.py +petstore_api/model/array_test.py +petstore_api/model/capitalization.py +petstore_api/model/cat.py +petstore_api/model/cat_all_of.py +petstore_api/model/category.py +petstore_api/model/child.py +petstore_api/model/child_all_of.py +petstore_api/model/child_cat.py +petstore_api/model/child_cat_all_of.py +petstore_api/model/child_dog.py +petstore_api/model/child_dog_all_of.py +petstore_api/model/child_lizard.py +petstore_api/model/child_lizard_all_of.py +petstore_api/model/class_model.py +petstore_api/model/client.py +petstore_api/model/dog.py +petstore_api/model/dog_all_of.py +petstore_api/model/enum_arrays.py +petstore_api/model/enum_class.py +petstore_api/model/enum_test.py +petstore_api/model/file.py +petstore_api/model/file_schema_test_class.py +petstore_api/model/format_test.py +petstore_api/model/grandparent.py +petstore_api/model/grandparent_animal.py +petstore_api/model/has_only_read_only.py +petstore_api/model/list.py +petstore_api/model/map_test.py +petstore_api/model/mixed_properties_and_additional_properties_class.py +petstore_api/model/model200_response.py +petstore_api/model/model_return.py +petstore_api/model/name.py +petstore_api/model/number_only.py +petstore_api/model/number_with_validations.py +petstore_api/model/object_model_with_ref_props.py +petstore_api/model/order.py +petstore_api/model/parent.py +petstore_api/model/parent_all_of.py +petstore_api/model/parent_pet.py +petstore_api/model/pet.py +petstore_api/model/player.py +petstore_api/model/read_only_first.py +petstore_api/model/special_model_name.py +petstore_api/model/string_boolean_map.py +petstore_api/model/string_enum.py +petstore_api/model/tag.py +petstore_api/model/type_holder_default.py +petstore_api/model/type_holder_example.py +petstore_api/model/user.py +petstore_api/model/xml_item.py +petstore_api/model_utils.py +petstore_api/models/__init__.py +petstore_api/models/__init__.py +petstore_api/rest.py +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +tox.ini diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION new file mode 100644 index 00000000000..d509cc92aa8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.1.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.travis.yml b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.travis.yml new file mode 100644 index 00000000000..1fcc4b15596 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.travis.yml @@ -0,0 +1,13 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.6" + - "3.7" + - "3.8" + - "3.9" +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +script: pytest --cov=petstore_api diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/Makefile b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/Makefile new file mode 100644 index 00000000000..a6bbba4a434 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/Makefile @@ -0,0 +1,18 @@ + #!/bin/bash + +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=venv + +clean: + rm -rf $(REQUIREMENTS_OUT) + rm -rf $(SETUP_OUT) + rm -rf $(VENV) + rm -rf .tox + rm -rf .coverage + find . -name "*.py[oc]" -delete + find . -name "__pycache__" -delete + +test: clean + bash ./test_python.sh diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/README.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/README.md new file mode 100644 index 00000000000..5f53c0f6423 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/README.md @@ -0,0 +1,247 @@ +# petstore-api +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python >= 3.6 + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) + +Then import the package: +```python +import petstore_api +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import petstore_api +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import time +import petstore_api +from pprint import pprint +from petstore_api.api import another_fake_api +from petstore_api.model.client import Client +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = another_fake_api.AnotherFakeApi(api_client) + body = Client( + client="client_example", + ) # Client | client model + + try: + # To test special tags + api_response = api_instance.call_123_test_special_tags(body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*FakeApi* | [**array_model**](docs/FakeApi.md#array_model) | **POST** /fake/refs/arraymodel | +*FakeApi* | [**boolean**](docs/FakeApi.md#boolean) | **POST** /fake/refs/boolean | +*FakeApi* | [**create_xml_item**](docs/FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem +*FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number | +*FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | +*FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string | +*FakeApi* | [**string_enum**](docs/FakeApi.md#string_enum) | **POST** /fake/refs/enum | +*FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +*FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**test_endpoint_enums_length_one**](docs/FakeApi.md#test_endpoint_enums_length_one) | **PUT** /fake/enums-of-length-one/{path_string}/{path_integer} | +*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) + - [AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md) + - [AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md) + - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md) + - [AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md) + - [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) + - [AdditionalPropertiesString](docs/AdditionalPropertiesString.md) + - [Animal](docs/Animal.md) + - [AnimalFarm](docs/AnimalFarm.md) + - [ApiResponse](docs/ApiResponse.md) + - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) + - [ArrayTest](docs/ArrayTest.md) + - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) + - [CatAllOf](docs/CatAllOf.md) + - [Category](docs/Category.md) + - [Child](docs/Child.md) + - [ChildAllOf](docs/ChildAllOf.md) + - [ChildCat](docs/ChildCat.md) + - [ChildCatAllOf](docs/ChildCatAllOf.md) + - [ChildDog](docs/ChildDog.md) + - [ChildDogAllOf](docs/ChildDogAllOf.md) + - [ChildLizard](docs/ChildLizard.md) + - [ChildLizardAllOf](docs/ChildLizardAllOf.md) + - [ClassModel](docs/ClassModel.md) + - [Client](docs/Client.md) + - [Dog](docs/Dog.md) + - [DogAllOf](docs/DogAllOf.md) + - [EnumArrays](docs/EnumArrays.md) + - [EnumClass](docs/EnumClass.md) + - [EnumTest](docs/EnumTest.md) + - [File](docs/File.md) + - [FileSchemaTestClass](docs/FileSchemaTestClass.md) + - [FormatTest](docs/FormatTest.md) + - [Grandparent](docs/Grandparent.md) + - [GrandparentAnimal](docs/GrandparentAnimal.md) + - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [List](docs/List.md) + - [MapTest](docs/MapTest.md) + - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [NumberOnly](docs/NumberOnly.md) + - [NumberWithValidations](docs/NumberWithValidations.md) + - [ObjectModelWithRefProps](docs/ObjectModelWithRefProps.md) + - [Order](docs/Order.md) + - [Parent](docs/Parent.md) + - [ParentAllOf](docs/ParentAllOf.md) + - [ParentPet](docs/ParentPet.md) + - [Pet](docs/Pet.md) + - [Player](docs/Player.md) + - [ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [StringBooleanMap](docs/StringBooleanMap.md) + - [StringEnum](docs/StringEnum.md) + - [Tag](docs/Tag.md) + - [TypeHolderDefault](docs/TypeHolderDefault.md) + - [TypeHolderExample](docs/TypeHolderExample.md) + - [User](docs/User.md) + - [XmlItem](docs/XmlItem.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +## http_basic_test + +- **Type**: HTTP basic authentication + + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + + + + +## Notes for Large OpenAPI documents +If the OpenAPI document is large, imports in petstore_api.apis and petstore_api.models may fail with a +RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: + +Solution 1: +Use specific imports for apis and models like: +- `from petstore_api.api.default_api import DefaultApi` +- `from petstore_api.model.pet import Pet` + +Solution 2: +Before importing the package, adjust the maximum recursion limit as shown below: +``` +import sys +sys.setrecursionlimit(1500) +import petstore_api +from petstore_api.apis import * +from petstore_api.models import * +``` + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/dev-requirements.txt b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/dev-requirements.txt new file mode 100644 index 00000000000..ccdfca62949 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/dev-requirements.txt @@ -0,0 +1,2 @@ +tox +flake8 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesAnyType.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesAnyType.md new file mode 100644 index 00000000000..d31d12de082 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesAnyType.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesAnyType + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesArray.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesArray.md new file mode 100644 index 00000000000..40537cbf838 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesArray.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesArray + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **[bool, date, datetime, dict, float, int, list, str, none_type]** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesBoolean.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesBoolean.md new file mode 100644 index 00000000000..bf7b5be4c13 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesBoolean.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesBoolean + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesClass.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..fe54cef0539 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesClass.md @@ -0,0 +1,21 @@ +# AdditionalPropertiesClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_string** | **{str: (str,)}** | | [optional] +**map_number** | **{str: (float,)}** | | [optional] +**map_integer** | **{str: (int,)}** | | [optional] +**map_boolean** | **{str: (bool,)}** | | [optional] +**map_array_integer** | **{str: ([int],)}** | | [optional] +**map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str, none_type],)}** | | [optional] +**map_map_string** | **{str: ({str: (str,)},)}** | | [optional] +**map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)}** | | [optional] +**anytype_1** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**anytype_2** | **bool, date, datetime, dict, float, int, list, str, none_type** | no type is set for this | [optional] +**anytype_3** | **bool, date, datetime, dict, float, int, list, str, none_type** | because of a bug in swagger-parser, this should have values {str: (str, int, float...)} but instead we get any type. See https://github.com/swagger-api/swagger-parser/issues/1378 | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesInteger.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesInteger.md new file mode 100644 index 00000000000..96345efd4cc --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesInteger.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesInteger + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **int** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesNumber.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesNumber.md new file mode 100644 index 00000000000..9af52dc6dcf --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesNumber.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesNumber + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **float** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesObject.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesObject.md new file mode 100644 index 00000000000..dc64a0d91c2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesObject.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesObject + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type,)}** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesString.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesString.md new file mode 100644 index 00000000000..fe3993d0226 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AdditionalPropertiesString.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesString + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **str** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Animal.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Animal.md new file mode 100644 index 00000000000..1d1c77c01ab --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Animal.md @@ -0,0 +1,12 @@ +# Animal + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**color** | **str** | | [optional] if omitted the server will use the default value of "red" + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnimalFarm.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnimalFarm.md new file mode 100644 index 00000000000..fc299cf27d3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnimalFarm.md @@ -0,0 +1,11 @@ +# AnimalFarm + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | [**[Animal]**](Animal.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnotherFakeApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnotherFakeApi.md new file mode 100644 index 00000000000..470caed72cc --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/AnotherFakeApi.md @@ -0,0 +1,76 @@ +# petstore_api.AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags + + +# **call_123_test_special_tags** +> Client call_123_test_special_tags(body) + +To test special tags + +To test special tags and operation ID starting with number + +### Example + +```python +import time +import petstore_api +from petstore_api.api import another_fake_api +from petstore_api.model.client import Client +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = another_fake_api.AnotherFakeApi(api_client) + body = Client( + client="client_example", + ) # Client | client model + + # example passing only required values which don't have defaults set + try: + # To test special tags + api_response = api_instance.call_123_test_special_tags(body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ApiResponse.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ApiResponse.md new file mode 100644 index 00000000000..81a7d0d8522 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ApiResponse.md @@ -0,0 +1,13 @@ +# ApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] +**type** | **str** | | [optional] +**message** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 00000000000..6ab77963788 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,11 @@ +# ArrayOfArrayOfNumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_array_number** | **[[float]]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfNumberOnly.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfNumberOnly.md new file mode 100644 index 00000000000..ebc65a54ba7 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayOfNumberOnly.md @@ -0,0 +1,11 @@ +# ArrayOfNumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_number** | **[float]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayTest.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayTest.md new file mode 100644 index 00000000000..4e1bda8fc3a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ArrayTest.md @@ -0,0 +1,13 @@ +# ArrayTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_string** | **[str]** | | [optional] +**array_array_of_integer** | **[[int]]** | | [optional] +**array_array_of_model** | [**[[ReadOnlyFirst]]**](ReadOnlyFirst.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Capitalization.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Capitalization.md new file mode 100644 index 00000000000..1ddeadeb3f4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Capitalization.md @@ -0,0 +1,16 @@ +# Capitalization + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **str** | | [optional] +**capital_camel** | **str** | | [optional] +**small_snake** | **str** | | [optional] +**capital_snake** | **str** | | [optional] +**sca_eth_flow_points** | **str** | | [optional] +**att_name** | **str** | Name of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Cat.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Cat.md new file mode 100644 index 00000000000..e9ce235cd63 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Cat.md @@ -0,0 +1,13 @@ +# Cat + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**declawed** | **bool** | | [optional] +**color** | **str** | | [optional] if omitted the server will use the default value of "red" + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/CatAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/CatAllOf.md new file mode 100644 index 00000000000..0ff7809a99a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/CatAllOf.md @@ -0,0 +1,11 @@ +# CatAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Category.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Category.md new file mode 100644 index 00000000000..940f6a45e64 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Category.md @@ -0,0 +1,12 @@ +# Category + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | defaults to "default-name" +**id** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Child.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Child.md new file mode 100644 index 00000000000..eb439244571 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Child.md @@ -0,0 +1,13 @@ +# Child + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [optional] +**tele_vision** | **bool** | | [optional] +**inter_net** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildAllOf.md new file mode 100644 index 00000000000..f9ae99c7c15 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildAllOf.md @@ -0,0 +1,11 @@ +# ChildAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**inter_net** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCat.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCat.md new file mode 100644 index 00000000000..9e3a0fb4b51 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCat.md @@ -0,0 +1,12 @@ +# ChildCat + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCatAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCatAllOf.md new file mode 100644 index 00000000000..c5883b9a87c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildCatAllOf.md @@ -0,0 +1,11 @@ +# ChildCatAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDog.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDog.md new file mode 100644 index 00000000000..9a6e5b37266 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDog.md @@ -0,0 +1,12 @@ +# ChildDog + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**bark** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDogAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDogAllOf.md new file mode 100644 index 00000000000..673050667cb --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildDogAllOf.md @@ -0,0 +1,11 @@ +# ChildDogAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bark** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizard.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizard.md new file mode 100644 index 00000000000..e881ee0a1d1 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizard.md @@ -0,0 +1,12 @@ +# ChildLizard + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**loves_rocks** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizardAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizardAllOf.md new file mode 100644 index 00000000000..6e2b70c0150 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ChildLizardAllOf.md @@ -0,0 +1,11 @@ +# ChildLizardAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loves_rocks** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ClassModel.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ClassModel.md new file mode 100644 index 00000000000..48ed7cbf2ff --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ClassModel.md @@ -0,0 +1,12 @@ +# ClassModel + +Model for testing model with \"_class\" property + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_class** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Client.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Client.md new file mode 100644 index 00000000000..c3986008d6c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Client.md @@ -0,0 +1,11 @@ +# Client + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Dog.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Dog.md new file mode 100644 index 00000000000..7065c4c983d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Dog.md @@ -0,0 +1,13 @@ +# Dog + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**breed** | **str** | | [optional] +**color** | **str** | | [optional] if omitted the server will use the default value of "red" + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/DogAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/DogAllOf.md new file mode 100644 index 00000000000..6382bbd8067 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/DogAllOf.md @@ -0,0 +1,11 @@ +# DogAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumArrays.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumArrays.md new file mode 100644 index 00000000000..9be5c645a80 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumArrays.md @@ -0,0 +1,12 @@ +# EnumArrays + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **str** | | [optional] +**array_enum** | **[str]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumClass.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumClass.md new file mode 100644 index 00000000000..a1f9aae5819 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumClass.md @@ -0,0 +1,11 @@ +# EnumClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **str** | | defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumTest.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumTest.md new file mode 100644 index 00000000000..eb884224139 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/EnumTest.md @@ -0,0 +1,15 @@ +# EnumTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string_required** | **str** | | +**enum_string** | **str** | | [optional] +**enum_integer** | **int** | | [optional] +**enum_number** | **float** | | [optional] +**string_enum** | [**StringEnum**](StringEnum.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md new file mode 100644 index 00000000000..a107342b75c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md @@ -0,0 +1,1205 @@ +# petstore_api.FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**array_model**](FakeApi.md#array_model) | **POST** /fake/refs/arraymodel | +[**boolean**](FakeApi.md#boolean) | **POST** /fake/refs/boolean | +[**create_xml_item**](FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem +[**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number | +[**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | +[**string**](FakeApi.md#string) | **POST** /fake/refs/string | +[**string_enum**](FakeApi.md#string_enum) | **POST** /fake/refs/enum | +[**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +[**test_endpoint_enums_length_one**](FakeApi.md#test_endpoint_enums_length_one) | **PUT** /fake/enums-of-length-one/{path_string}/{path_integer} | +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data + + +# **array_model** +> AnimalFarm array_model() + + + +Test serialization of ArrayModel + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.animal_farm import AnimalFarm +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = AnimalFarm([ + Animal(), + ]) # AnimalFarm | Input model (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.array_model(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->array_model: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**AnimalFarm**](AnimalFarm.md)| Input model | [optional] + +### Return type + +[**AnimalFarm**](AnimalFarm.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output model | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **boolean** +> bool boolean() + + + +Test serialization of outer boolean types + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = True # bool | Input boolean as post body (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.boolean(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->boolean: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **bool**| Input boolean as post body | [optional] + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output boolean | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_xml_item** +> create_xml_item(xml_item) + +creates an XmlItem + +this route creates an XmlItem + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.xml_item import XmlItem +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + xml_item = XmlItem( + attribute_string="string", + attribute_number=1.234, + attribute_integer=-2, + attribute_boolean=True, + wrapped_array=[ + 1, + ], + name_string="string", + name_number=1.234, + name_integer=-2, + name_boolean=True, + name_array=[ + 1, + ], + name_wrapped_array=[ + 1, + ], + prefix_string="string", + prefix_number=1.234, + prefix_integer=-2, + prefix_boolean=True, + prefix_array=[ + 1, + ], + prefix_wrapped_array=[ + 1, + ], + namespace_string="string", + namespace_number=1.234, + namespace_integer=-2, + namespace_boolean=True, + namespace_array=[ + 1, + ], + namespace_wrapped_array=[ + 1, + ], + prefix_ns_string="string", + prefix_ns_number=1.234, + prefix_ns_integer=-2, + prefix_ns_boolean=True, + prefix_ns_array=[ + 1, + ], + prefix_ns_wrapped_array=[ + 1, + ], + ) # XmlItem | XmlItem Body + + # example passing only required values which don't have defaults set + try: + # creates an XmlItem + api_instance.create_xml_item(xml_item) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->create_xml_item: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xml_item** | [**XmlItem**](XmlItem.md)| XmlItem Body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16 + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **number_with_validations** +> NumberWithValidations number_with_validations() + + + +Test serialization of outer number types + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.number_with_validations import NumberWithValidations +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = NumberWithValidations(1E+1) # NumberWithValidations | Input number as post body (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.number_with_validations(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->number_with_validations: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**NumberWithValidations**](NumberWithValidations.md)| Input number as post body | [optional] + +### Return type + +[**NumberWithValidations**](NumberWithValidations.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output number | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **object_model_with_ref_props** +> ObjectModelWithRefProps object_model_with_ref_props() + + + +Test serialization of object with $refed properties + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = ObjectModelWithRefProps( + my_number=NumberWithValidations(1E+1), + my_string="my_string_example", + my_boolean=True, + ) # ObjectModelWithRefProps | Input model (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.object_model_with_ref_props(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->object_model_with_ref_props: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ObjectModelWithRefProps**](ObjectModelWithRefProps.md)| Input model | [optional] + +### Return type + +[**ObjectModelWithRefProps**](ObjectModelWithRefProps.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output model | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **string** +> str string() + + + +Test serialization of outer string types + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = "body_example" # str | Input string as post body (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.string(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->string: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **str**| Input string as post body | [optional] + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output string | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **string_enum** +> StringEnum string_enum() + + + +Test serialization of outer enum + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.string_enum import StringEnum +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = StringEnum("placed") # StringEnum | Input enum (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.string_enum(body=body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->string_enum: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**StringEnum**](StringEnum.md)| Input enum | [optional] + +### Return type + +[**StringEnum**](StringEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output enum | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_body_with_file_schema** +> test_body_with_file_schema(body) + + + +For this test, the body for this request much reference a schema named `File`. + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.file_schema_test_class import FileSchemaTestClass +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = FileSchemaTestClass( + file=File( + source_uri="source_uri_example", + ), + files=[ + File( + source_uri="source_uri_example", + ), + ], + ) # FileSchemaTestClass | + + # example passing only required values which don't have defaults set + try: + api_instance.test_body_with_file_schema(body) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_body_with_query_params** +> test_body_with_query_params(query, body) + + + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + query = "query_example" # str | + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | + + # example passing only required values which don't have defaults set + try: + api_instance.test_body_with_query_params(query, body) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **str**| | + **body** | [**User**](User.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_client_model** +> Client test_client_model(body) + +To test \"client\" model + +To test \"client\" model + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.client import Client +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + body = Client( + client="client_example", + ) # Client | client model + + # example passing only required values which don't have defaults set + try: + # To test \"client\" model + api_response = api_instance.test_client_model(body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_client_model: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_endpoint_enums_length_one** +> test_endpoint_enums_length_one() + + + +This route has required values with enums of 1 + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + + # example passing only required values which don't have defaults set + try: + api_instance.test_endpoint_enums_length_one() + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_endpoint_enums_length_one: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_integer** | **int**| | defaults to 3 + **query_string** | **str**| | defaults to "brillig" + **path_string** | **str**| | defaults to "hello" + **path_integer** | **int**| | defaults to 34 + **header_number** | **float**| | defaults to 1.234 + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_endpoint_parameters** +> test_endpoint_parameters(number, double, pattern_without_delimiter, byte) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example + +* Basic Authentication (http_basic_test): +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: http_basic_test +configuration = petstore_api.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + number = 32.1 # float | None + double = 67.8 # float | None + pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + byte = 'YQ==' # str | None + integer = 10 # int | None (optional) + int32 = 20 # int | None (optional) + int64 = 1 # int | None (optional) + float = 3.14 # float | None (optional) + string = "a" # str | None (optional) + binary = open('/path/to/file', 'rb') # file_type | None (optional) + date = dateutil_parser('1970-01-01').date() # date | None (optional) + date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional) + password = "password_example" # str | None (optional) + param_callback = "param_callback_example" # str | None (optional) + + # example passing only required values which don't have defaults set + try: + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **float**| None | + **double** | **float**| None | + **pattern_without_delimiter** | **str**| None | + **byte** | **str**| None | + **integer** | **int**| None | [optional] + **int32** | **int**| None | [optional] + **int64** | **int**| None | [optional] + **float** | **float**| None | [optional] + **string** | **str**| None | [optional] + **binary** | **file_type**| None | [optional] + **date** | **date**| None | [optional] + **date_time** | **datetime**| None | [optional] + **password** | **str**| None | [optional] + **param_callback** | **str**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_enum_parameters** +> test_enum_parameters() + +To test enum parameters + +To test enum parameters + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + enum_header_string_array = [ + "$", + ] # [str] | Header parameter enum test (string array) (optional) + enum_header_string = "-efg" # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_string_array = [ + "$", + ] # [str] | Query parameter enum test (string array) (optional) + enum_query_string = "-efg" # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_integer = 1 # int | Query parameter enum test (double) (optional) + enum_query_double = 1.1 # float | Query parameter enum test (double) (optional) + enum_form_string_array = "$" # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of "$" + enum_form_string = "-efg" # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + + # example passing only required values which don't have defaults set + # and optional values + try: + # To test enum parameters + api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional] + **enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" + **enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional] + **enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" + **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] + **enum_query_double** | **float**| Query parameter enum test (double) | [optional] + **enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of "$" + **enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid request | - | +**404** | Not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_group_parameters** +> test_group_parameters(required_string_group, required_boolean_group, required_int64_group) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + required_string_group = 1 # int | Required String in group parameters + required_boolean_group = True # bool | Required Boolean in group parameters + required_int64_group = 1 # int | Required Integer in group parameters + string_group = 1 # int | String in group parameters (optional) + boolean_group = True # bool | Boolean in group parameters (optional) + int64_group = 1 # int | Integer in group parameters (optional) + + # example passing only required values which don't have defaults set + try: + # Fake endpoint to test group parameters (optional) + api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_group_parameters: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # Fake endpoint to test group parameters (optional) + api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_group_parameters: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **required_string_group** | **int**| Required String in group parameters | + **required_boolean_group** | **bool**| Required Boolean in group parameters | + **required_int64_group** | **int**| Required Integer in group parameters | + **string_group** | **int**| String in group parameters | [optional] + **boolean_group** | **bool**| Boolean in group parameters | [optional] + **int64_group** | **int**| Integer in group parameters | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Someting wrong | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_inline_additional_properties** +> test_inline_additional_properties(param) + +test inline additionalProperties + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + param = { + "key": "key_example", + } # {str: (str,)} | request body + + # example passing only required values which don't have defaults set + try: + # test inline additionalProperties + api_instance.test_inline_additional_properties(param) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **{str: (str,)}**| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_json_form_data** +> test_json_form_data(param, param2) + +test json serialization of form data + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + param = "param_example" # str | field1 + param2 = "param2_example" # str | field2 + + # example passing only required values which don't have defaults set + try: + # test json serialization of form data + api_instance.test_json_form_data(param, param2) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_json_form_data: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **str**| field1 | + **param2** | **str**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeClassnameTags123Api.md new file mode 100644 index 00000000000..3452fd6ddff --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeClassnameTags123Api.md @@ -0,0 +1,87 @@ +# petstore_api.FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_classname**](FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **test_classname** +> Client test_classname(body) + +To test class name in snake case + +To test class name in snake case + +### Example + +* Api Key Authentication (api_key_query): +```python +import time +import petstore_api +from petstore_api.api import fake_classname_tags_123_api +from petstore_api.model.client import Client +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key_query +configuration.api_key['api_key_query'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key_query'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client) + body = Client( + client="client_example", + ) # Client | client model + + # example passing only required values which don't have defaults set + try: + # To test class name in snake case + api_response = api_instance.test_classname(body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/File.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/File.md new file mode 100644 index 00000000000..63b1d1a6518 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/File.md @@ -0,0 +1,12 @@ +# File + +Must be named `File` for test. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**source_uri** | **str** | Test capitalization | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FileSchemaTestClass.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FileSchemaTestClass.md new file mode 100644 index 00000000000..caf2440821d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FileSchemaTestClass.md @@ -0,0 +1,12 @@ +# FileSchemaTestClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**file** | [**File**](File.md) | | [optional] +**files** | [**[File]**](File.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FormatTest.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FormatTest.md new file mode 100644 index 00000000000..aef09bfcc83 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FormatTest.md @@ -0,0 +1,23 @@ +# FormatTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | **float** | | +**byte** | **str** | | +**date** | **date** | | +**password** | **str** | | +**integer** | **int** | | [optional] +**int32** | **int** | | [optional] +**int64** | **int** | | [optional] +**float** | **float** | | [optional] +**double** | **float** | | [optional] +**string** | **str** | | [optional] +**binary** | **file_type** | | [optional] +**date_time** | **datetime** | | [optional] +**uuid** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Grandparent.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Grandparent.md new file mode 100644 index 00000000000..b6d80a71945 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Grandparent.md @@ -0,0 +1,11 @@ +# Grandparent + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/GrandparentAnimal.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/GrandparentAnimal.md new file mode 100644 index 00000000000..15db0708bb1 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/GrandparentAnimal.md @@ -0,0 +1,11 @@ +# GrandparentAnimal + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/HasOnlyReadOnly.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/HasOnlyReadOnly.md new file mode 100644 index 00000000000..0e1334519a8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/HasOnlyReadOnly.md @@ -0,0 +1,12 @@ +# HasOnlyReadOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] [readonly] +**foo** | **str** | | [optional] [readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/List.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/List.md new file mode 100644 index 00000000000..4b60956971a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/List.md @@ -0,0 +1,11 @@ +# List + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123_list** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MapTest.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MapTest.md new file mode 100644 index 00000000000..15228ee1f28 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MapTest.md @@ -0,0 +1,14 @@ +# MapTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_map_of_string** | **{str: ({str: (str,)},)}** | | [optional] +**map_of_enum_string** | **{str: (str,)}** | | [optional] +**direct_map** | **{str: (bool,)}** | | [optional] +**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..f489944a20a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,13 @@ +# MixedPropertiesAndAdditionalPropertiesClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | [optional] +**date_time** | **datetime** | | [optional] +**map** | [**{str: (Animal,)}**](Animal.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Model200Response.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Model200Response.md new file mode 100644 index 00000000000..c958bd4b33f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Model200Response.md @@ -0,0 +1,13 @@ +# Model200Response + +Model for testing model name starting with number + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**_class** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ModelReturn.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ModelReturn.md new file mode 100644 index 00000000000..043e9d466fa --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ModelReturn.md @@ -0,0 +1,12 @@ +# ModelReturn + +Model for testing reserved words + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Name.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Name.md new file mode 100644 index 00000000000..3be719cdbfb --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Name.md @@ -0,0 +1,15 @@ +# Name + +Model for testing model name same as property name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | +**snake_case** | **int** | | [optional] [readonly] +**_property** | **str** | | [optional] +**_123_number** | **int** | | [optional] [readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberOnly.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberOnly.md new file mode 100644 index 00000000000..37195c5d899 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberOnly.md @@ -0,0 +1,11 @@ +# NumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_number** | **float** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberWithValidations.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberWithValidations.md new file mode 100644 index 00000000000..119e0f67823 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/NumberWithValidations.md @@ -0,0 +1,11 @@ +# NumberWithValidations + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **float** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ObjectModelWithRefProps.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ObjectModelWithRefProps.md new file mode 100644 index 00000000000..5ff4e52033d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ObjectModelWithRefProps.md @@ -0,0 +1,14 @@ +# ObjectModelWithRefProps + +a model that includes properties which should stay primitive (String + Boolean) and one which is defined as a class, NumberWithValidations + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**my_number** | [**NumberWithValidations**](NumberWithValidations.md) | | [optional] +**my_string** | **str** | | [optional] +**my_boolean** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Order.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Order.md new file mode 100644 index 00000000000..d29e1a381de --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Order.md @@ -0,0 +1,16 @@ +# Order + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | **datetime** | | [optional] +**status** | **str** | Order Status | [optional] +**complete** | **bool** | | [optional] if omitted the server will use the default value of False + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Parent.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Parent.md new file mode 100644 index 00000000000..9d3f02d68b3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Parent.md @@ -0,0 +1,12 @@ +# Parent + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [optional] +**tele_vision** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentAllOf.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentAllOf.md new file mode 100644 index 00000000000..569a5e4af14 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentAllOf.md @@ -0,0 +1,11 @@ +# ParentAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tele_vision** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentPet.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentPet.md new file mode 100644 index 00000000000..09e409c8fcf --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ParentPet.md @@ -0,0 +1,11 @@ +# ParentPet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Pet.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Pet.md new file mode 100644 index 00000000000..6e78495272e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Pet.md @@ -0,0 +1,16 @@ +# Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**photo_urls** | **[str]** | | +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**tags** | [**[Tag]**](Tag.md) | | [optional] +**status** | **str** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/PetApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/PetApi.md new file mode 100644 index 00000000000..dcff2fcd072 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/PetApi.md @@ -0,0 +1,782 @@ +# petstore_api.PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) + + +# **add_pet** +> add_pet(body) + +Add a new pet to the store + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.pet import Pet +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + body = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + full_name="full_name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + + # example passing only required values which don't have defaults set + try: + # Add a new pet to the store + api_instance.add_pet(body) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->add_pet: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet(pet_id) + +Deletes a pet + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + pet_id = 1 # int | Pet id to delete + api_key = "api_key_example" # str | (optional) + + # example passing only required values which don't have defaults set + try: + # Deletes a pet + api_instance.delete_pet(pet_id) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->delete_pet: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # Deletes a pet + api_instance.delete_pet(pet_id, api_key=api_key) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->delete_pet: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid pet value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> [Pet] find_pets_by_status(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.pet import Pet +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + status = [ + "available", + ] # [str] | Status values that need to be considered for filter + + # example passing only required values which don't have defaults set + try: + # Finds Pets by status + api_response = api_instance.find_pets_by_status(status) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->find_pets_by_status: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **[str]**| Status values that need to be considered for filter | + +### Return type + +[**[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid status value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> [Pet] find_pets_by_tags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.pet import Pet +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + tags = [ + "tags_example", + ] # [str] | Tags to filter by + + # example passing only required values which don't have defaults set + try: + # Finds Pets by tags + api_response = api_instance.find_pets_by_tags(tags) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | **[str]**| Tags to filter by | + +### Return type + +[**[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid tag value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id) + +Find pet by ID + +Returns a single pet + +### Example + +* Api Key Authentication (api_key): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.pet import Pet +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key +configuration.api_key['api_key'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + pet_id = 1 # int | ID of pet to return + + # example passing only required values which don't have defaults set + try: + # Find pet by ID + api_response = api_instance.get_pet_by_id(pet_id) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Pet not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet(body) + +Update an existing pet + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.pet import Pet +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + body = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + full_name="full_name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + + # example passing only required values which don't have defaults set + try: + # Update an existing pet + api_instance.update_pet(body) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->update_pet: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Pet not found | - | +**405** | Validation exception | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form(pet_id) + +Updates a pet in the store with form data + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + pet_id = 1 # int | ID of pet that needs to be updated + name = "name_example" # str | Updated name of the pet (optional) + status = "status_example" # str | Updated status of the pet (optional) + + # example passing only required values which don't have defaults set + try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->update_pet_with_form: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id, name=name, status=status) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->update_pet_with_form: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be updated | + **name** | **str**| Updated name of the pet | [optional] + **status** | **str**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file** +> ApiResponse upload_file(pet_id) + +uploads an image + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.api_response import ApiResponse +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + pet_id = 1 # int | ID of pet to update + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) + file = open('/path/to/file', 'rb') # file_type | file to upload (optional) + files = # [file_type] | files to upload (optional) + + # example passing only required values which don't have defaults set + try: + # uploads an image + api_response = api_instance.upload_file(pet_id) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # uploads an image + api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + **file** | **file_type**| file to upload | [optional] + **files** | **[file_type]**| files to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file_with_required_file** +> ApiResponse upload_file_with_required_file(pet_id, required_file) + +uploads an image (required) + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import petstore_api +from petstore_api.api import pet_api +from petstore_api.model.api_response import ApiResponse +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure OAuth2 access token for authorization: petstore_auth +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = pet_api.PetApi(api_client) + pet_id = 1 # int | ID of pet to update + required_file = open('/path/to/file', 'rb') # file_type | file to upload + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) + + # example passing only required values which don't have defaults set + try: + # uploads an image (required) + api_response = api_instance.upload_file_with_required_file(pet_id, required_file) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + # uploads an image (required) + api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **required_file** | **file_type**| file to upload | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Player.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Player.md new file mode 100644 index 00000000000..2014198aa1b --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Player.md @@ -0,0 +1,12 @@ +# Player + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**enemy_player** | [**Player**](Player.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ReadOnlyFirst.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ReadOnlyFirst.md new file mode 100644 index 00000000000..53b4c61d844 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/ReadOnlyFirst.md @@ -0,0 +1,12 @@ +# ReadOnlyFirst + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] [readonly] +**baz** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/SpecialModelName.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/SpecialModelName.md new file mode 100644 index 00000000000..268e1134192 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/SpecialModelName.md @@ -0,0 +1,11 @@ +# SpecialModelName + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StoreApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StoreApi.md new file mode 100644 index 00000000000..b5df4fc1fee --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StoreApi.md @@ -0,0 +1,285 @@ +# petstore_api.StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```python +import time +import petstore_api +from petstore_api.api import store_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = store_api.StoreApi(api_client) + order_id = "order_id_example" # str | ID of the order that needs to be deleted + + # example passing only required values which don't have defaults set + try: + # Delete purchase order by ID + api_instance.delete_order(order_id) + except petstore_api.ApiException as e: + print("Exception when calling StoreApi->delete_order: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid ID supplied | - | +**404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inventory** +> {str: (int,)} get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +* Api Key Authentication (api_key): +```python +import time +import petstore_api +from petstore_api.api import store_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key +configuration.api_key['api_key'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = store_api.StoreApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + # Returns pet inventories by status + api_response = api_instance.get_inventory() + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling StoreApi->get_inventory: %s\n" % e) +``` + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**{str: (int,)}** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_order_by_id** +> Order get_order_by_id(order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example + +```python +import time +import petstore_api +from petstore_api.api import store_api +from petstore_api.model.order import Order +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = store_api.StoreApi(api_client) + order_id = 1 # int | ID of pet that needs to be fetched + + # example passing only required values which don't have defaults set + try: + # Find purchase order by ID + api_response = api_instance.get_order_by_id(order_id) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling StoreApi->get_order_by_id: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **place_order** +> Order place_order(body) + +Place an order for a pet + +### Example + +```python +import time +import petstore_api +from petstore_api.api import store_api +from petstore_api.model.order import Order +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = store_api.StoreApi(api_client) + body = Order( + id=1, + pet_id=1, + quantity=1, + ship_date=dateutil_parser('1970-01-01T00:00:00.00Z'), + status="placed", + complete=False, + ) # Order | order placed for purchasing the pet + + # example passing only required values which don't have defaults set + try: + # Place an order for a pet + api_response = api_instance.place_order(body) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling StoreApi->place_order: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid Order | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringBooleanMap.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringBooleanMap.md new file mode 100644 index 00000000000..217c7970408 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringBooleanMap.md @@ -0,0 +1,11 @@ +# StringBooleanMap + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringEnum.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringEnum.md new file mode 100644 index 00000000000..bb195ec0e45 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/StringEnum.md @@ -0,0 +1,11 @@ +# StringEnum + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **str** | | must be one of ["placed", "approved", "delivered", ] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Tag.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Tag.md new file mode 100644 index 00000000000..b9fe1e0944c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/Tag.md @@ -0,0 +1,13 @@ +# Tag + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] +**full_name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderDefault.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderDefault.md new file mode 100644 index 00000000000..904915aec01 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderDefault.md @@ -0,0 +1,18 @@ +# TypeHolderDefault + +a model to test optional properties with server defaults + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_item** | **[int]** | | +**string_item** | **str** | | defaults to "what" +**number_item** | **float** | | defaults to 1.234 +**integer_item** | **int** | | defaults to -2 +**bool_item** | **bool** | | defaults to True +**date_item** | **date** | | [optional] +**datetime_item** | **datetime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderExample.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderExample.md new file mode 100644 index 00000000000..d2954c64dce --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/TypeHolderExample.md @@ -0,0 +1,16 @@ +# TypeHolderExample + +a model to test required properties with an example and length one enum + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bool_item** | **bool** | | +**array_item** | **[int]** | | +**string_item** | **str** | | defaults to "what" +**number_item** | **float** | | defaults to 1.234 +**integer_item** | **int** | | defaults to -2 + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/User.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/User.md new file mode 100644 index 00000000000..b0079f591b6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/User.md @@ -0,0 +1,18 @@ +# User + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **str** | | [optional] +**first_name** | **str** | | [optional] +**last_name** | **str** | | [optional] +**email** | **str** | | [optional] +**password** | **str** | | [optional] +**phone** | **str** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/UserApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/UserApi.md new file mode 100644 index 00000000000..3c04b81d196 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/UserApi.md @@ -0,0 +1,562 @@ +# petstore_api.UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(body) + +Create user + +This can only be done by the logged in user. + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | Created user object + + # example passing only required values which don't have defaults set + try: + # Create user + api_instance.create_user(body) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->create_user: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input(body) + +Creates list of users with given input array + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + body = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ), + ] # [User] | List of user object + + # example passing only required values which don't have defaults set + try: + # Creates list of users with given input array + api_instance.create_users_with_array_input(body) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**[User]**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input(body) + +Creates list of users with given input array + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + body = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ), + ] # [User] | List of user object + + # example passing only required values which don't have defaults set + try: + # Creates list of users with given input array + api_instance.create_users_with_list_input(body) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**[User]**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + username = "username_example" # str | The name that needs to be deleted + + # example passing only required values which don't have defaults set + try: + # Delete user + api_instance.delete_user(username) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->delete_user: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_user_by_name** +> User get_user_by_name(username) + +Get user by user name + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + username = "username_example" # str | The name that needs to be fetched. Use user1 for testing. + + # example passing only required values which don't have defaults set + try: + # Get user by user name + api_response = api_instance.get_user_by_name(username) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->get_user_by_name: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **login_user** +> str login_user(username, password) + +Logs user into the system + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + username = "username_example" # str | The user name for login + password = "password_example" # str | The password for login in clear text + + # example passing only required values which don't have defaults set + try: + # Logs user into the system + api_response = api_instance.login_user(username, password) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->login_user: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The user name for login | + **password** | **str**| The password for login in clear text | + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | * X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +**400** | Invalid username/password supplied | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user() + +Logs out current logged in user session + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + # Logs out current logged in user session + api_instance.logout_user() + except petstore_api.ApiException as e: + print("Exception when calling UserApi->logout_user: %s\n" % e) +``` + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_user** +> update_user(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example + +```python +import time +import petstore_api +from petstore_api.api import user_api +from petstore_api.model.user import User +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = user_api.UserApi(api_client) + username = "username_example" # str | name that need to be deleted + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | Updated user object + + # example passing only required values which don't have defaults set + try: + # Updated user + api_instance.update_user(username, body) + except petstore_api.ApiException as e: + print("Exception when calling UserApi->update_user: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid user supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/XmlItem.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/XmlItem.md new file mode 100644 index 00000000000..ea3d7f92804 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/XmlItem.md @@ -0,0 +1,39 @@ +# XmlItem + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attribute_string** | **str** | | [optional] +**attribute_number** | **float** | | [optional] +**attribute_integer** | **int** | | [optional] +**attribute_boolean** | **bool** | | [optional] +**wrapped_array** | **[int]** | | [optional] +**name_string** | **str** | | [optional] +**name_number** | **float** | | [optional] +**name_integer** | **int** | | [optional] +**name_boolean** | **bool** | | [optional] +**name_array** | **[int]** | | [optional] +**name_wrapped_array** | **[int]** | | [optional] +**prefix_string** | **str** | | [optional] +**prefix_number** | **float** | | [optional] +**prefix_integer** | **int** | | [optional] +**prefix_boolean** | **bool** | | [optional] +**prefix_array** | **[int]** | | [optional] +**prefix_wrapped_array** | **[int]** | | [optional] +**namespace_string** | **str** | | [optional] +**namespace_number** | **float** | | [optional] +**namespace_integer** | **int** | | [optional] +**namespace_boolean** | **bool** | | [optional] +**namespace_array** | **[int]** | | [optional] +**namespace_wrapped_array** | **[int]** | | [optional] +**prefix_ns_string** | **str** | | [optional] +**prefix_ns_number** | **float** | | [optional] +**prefix_ns_integer** | **int** | | [optional] +**prefix_ns_boolean** | **bool** | | [optional] +**prefix_ns_array** | **[int]** | | [optional] +**prefix_ns_wrapped_array** | **[int]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/git_push.sh b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/git_push.sh new file mode 100644 index 00000000000..ced3be2b0c7 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/git_push.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/__init__.py new file mode 100644 index 00000000000..26dd6f84e21 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/__init__.py @@ -0,0 +1,27 @@ +# flake8: noqa + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +__version__ = "1.0.0" + +# import ApiClient +from petstore_api.api_client import ApiClient + +# import Configuration +from petstore_api.configuration import Configuration + +# import exceptions +from petstore_api.exceptions import OpenApiException +from petstore_api.exceptions import ApiAttributeError +from petstore_api.exceptions import ApiTypeError +from petstore_api.exceptions import ApiValueError +from petstore_api.exceptions import ApiKeyError +from petstore_api.exceptions import ApiException diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/__init__.py new file mode 100644 index 00000000000..840e9f0cd90 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/__init__.py @@ -0,0 +1,3 @@ +# do not import all apis into this module because that uses a lot of memory and stack frames +# if you need the ability to import all apis from one package, import them with +# from petstore_api.apis import AnotherFakeApi diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/another_fake_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/another_fake_api.py new file mode 100644 index 00000000000..9c75f7d5a83 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/another_fake_api.py @@ -0,0 +1,155 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.client import Client + + +class AnotherFakeApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __call_123_test_special_tags( + self, + body, + **kwargs + ): + """To test special tags # noqa: E501 + + To test special tags and operation ID starting with number # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.call_123_test_special_tags(body, async_req=True) + >>> result = thread.get() + + Args: + body (Client): client model + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.call_123_test_special_tags = _Endpoint( + settings={ + 'response_type': (Client,), + 'auth': [], + 'endpoint_path': '/another-fake/dummy', + 'operation_id': 'call_123_test_special_tags', + 'http_method': 'PATCH', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Client,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__call_123_test_special_tags + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_api.py new file mode 100644 index 00000000000..aaf44e6f64c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_api.py @@ -0,0 +1,2223 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.animal_farm import AnimalFarm +from petstore_api.model.client import Client +from petstore_api.model.file_schema_test_class import FileSchemaTestClass +from petstore_api.model.number_with_validations import NumberWithValidations +from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps +from petstore_api.model.string_enum import StringEnum +from petstore_api.model.user import User +from petstore_api.model.xml_item import XmlItem + + +class FakeApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __array_model( + self, + **kwargs + ): + """array_model # noqa: E501 + + Test serialization of ArrayModel # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.array_model(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (AnimalFarm): Input model. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + AnimalFarm + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.array_model = _Endpoint( + settings={ + 'response_type': (AnimalFarm,), + 'auth': [], + 'endpoint_path': '/fake/refs/arraymodel', + 'operation_id': 'array_model', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (AnimalFarm,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__array_model + ) + + def __boolean( + self, + **kwargs + ): + """boolean # noqa: E501 + + Test serialization of outer boolean types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.boolean(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (bool): Input boolean as post body. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + bool + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.boolean = _Endpoint( + settings={ + 'response_type': (bool,), + 'auth': [], + 'endpoint_path': '/fake/refs/boolean', + 'operation_id': 'boolean', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (bool,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__boolean + ) + + def __create_xml_item( + self, + xml_item, + **kwargs + ): + """creates an XmlItem # noqa: E501 + + this route creates an XmlItem # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_xml_item(xml_item, async_req=True) + >>> result = thread.get() + + Args: + xml_item (XmlItem): XmlItem Body + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['xml_item'] = \ + xml_item + return self.call_with_http_info(**kwargs) + + self.create_xml_item = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/create_xml_item', + 'operation_id': 'create_xml_item', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'xml_item', + ], + 'required': [ + 'xml_item', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'xml_item': + (XmlItem,), + }, + 'attribute_map': { + }, + 'location_map': { + 'xml_item': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/xml', + 'application/xml; charset=utf-8', + 'application/xml; charset=utf-16', + 'text/xml', + 'text/xml; charset=utf-8', + 'text/xml; charset=utf-16' + ] + }, + api_client=api_client, + callable=__create_xml_item + ) + + def __number_with_validations( + self, + **kwargs + ): + """number_with_validations # noqa: E501 + + Test serialization of outer number types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.number_with_validations(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (NumberWithValidations): Input number as post body. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + NumberWithValidations + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.number_with_validations = _Endpoint( + settings={ + 'response_type': (NumberWithValidations,), + 'auth': [], + 'endpoint_path': '/fake/refs/number', + 'operation_id': 'number_with_validations', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (NumberWithValidations,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__number_with_validations + ) + + def __object_model_with_ref_props( + self, + **kwargs + ): + """object_model_with_ref_props # noqa: E501 + + Test serialization of object with $refed properties # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.object_model_with_ref_props(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (ObjectModelWithRefProps): Input model. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + ObjectModelWithRefProps + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.object_model_with_ref_props = _Endpoint( + settings={ + 'response_type': (ObjectModelWithRefProps,), + 'auth': [], + 'endpoint_path': '/fake/refs/object_model_with_ref_props', + 'operation_id': 'object_model_with_ref_props', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (ObjectModelWithRefProps,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__object_model_with_ref_props + ) + + def __string( + self, + **kwargs + ): + """string # noqa: E501 + + Test serialization of outer string types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.string(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (str): Input string as post body. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + str + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.string = _Endpoint( + settings={ + 'response_type': (str,), + 'auth': [], + 'endpoint_path': '/fake/refs/string', + 'operation_id': 'string', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (str,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__string + ) + + def __string_enum( + self, + **kwargs + ): + """string_enum # noqa: E501 + + Test serialization of outer enum # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.string_enum(async_req=True) + >>> result = thread.get() + + + Keyword Args: + body (StringEnum): Input enum. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + StringEnum + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.string_enum = _Endpoint( + settings={ + 'response_type': (StringEnum,), + 'auth': [], + 'endpoint_path': '/fake/refs/enum', + 'operation_id': 'string_enum', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (StringEnum,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__string_enum + ) + + def __test_body_with_file_schema( + self, + body, + **kwargs + ): + """test_body_with_file_schema # noqa: E501 + + For this test, the body for this request much reference a schema named `File`. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_file_schema(body, async_req=True) + >>> result = thread.get() + + Args: + body (FileSchemaTestClass): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.test_body_with_file_schema = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/body-with-file-schema', + 'operation_id': 'test_body_with_file_schema', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (FileSchemaTestClass,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_body_with_file_schema + ) + + def __test_body_with_query_params( + self, + query, + body, + **kwargs + ): + """test_body_with_query_params # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_query_params(query, body, async_req=True) + >>> result = thread.get() + + Args: + query (str): + body (User): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['query'] = \ + query + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.test_body_with_query_params = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/body-with-query-params', + 'operation_id': 'test_body_with_query_params', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'query', + 'body', + ], + 'required': [ + 'query', + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'query': + (str,), + 'body': + (User,), + }, + 'attribute_map': { + 'query': 'query', + }, + 'location_map': { + 'query': 'query', + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_body_with_query_params + ) + + def __test_client_model( + self, + body, + **kwargs + ): + """To test \"client\" model # noqa: E501 + + To test \"client\" model # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_client_model(body, async_req=True) + >>> result = thread.get() + + Args: + body (Client): client model + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.test_client_model = _Endpoint( + settings={ + 'response_type': (Client,), + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_client_model', + 'http_method': 'PATCH', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Client,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_client_model + ) + + def __test_endpoint_enums_length_one( + self, + query_integer=3, + query_string="brillig", + path_string="hello", + path_integer=34, + header_number=1.234, + **kwargs + ): + """test_endpoint_enums_length_one # noqa: E501 + + This route has required values with enums of 1 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string="brillig", path_string="hello", path_integer=34, header_number=1.234, async_req=True) + >>> result = thread.get() + + Args: + query_integer (int): defaults to 3, must be one of [3] + query_string (str): defaults to "brillig", must be one of ["brillig"] + path_string (str): defaults to "hello", must be one of ["hello"] + path_integer (int): defaults to 34, must be one of [34] + header_number (float): defaults to 1.234, must be one of [1.234] + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['query_integer'] = \ + query_integer + kwargs['query_string'] = \ + query_string + kwargs['path_string'] = \ + path_string + kwargs['path_integer'] = \ + path_integer + kwargs['header_number'] = \ + header_number + return self.call_with_http_info(**kwargs) + + self.test_endpoint_enums_length_one = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/enums-of-length-one/{path_string}/{path_integer}', + 'operation_id': 'test_endpoint_enums_length_one', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'required': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'nullable': [ + ], + 'enum': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('query_integer',): { + + "3": 3 + }, + ('query_string',): { + + "BRILLIG": "brillig" + }, + ('path_string',): { + + "HELLO": "hello" + }, + ('path_integer',): { + + "34": 34 + }, + ('header_number',): { + + "1.234": 1.234 + }, + }, + 'openapi_types': { + 'query_integer': + (int,), + 'query_string': + (str,), + 'path_string': + (str,), + 'path_integer': + (int,), + 'header_number': + (float,), + }, + 'attribute_map': { + 'query_integer': 'query_integer', + 'query_string': 'query_string', + 'path_string': 'path_string', + 'path_integer': 'path_integer', + 'header_number': 'header_number', + }, + 'location_map': { + 'query_integer': 'query', + 'query_string': 'query', + 'path_string': 'path', + 'path_integer': 'path', + 'header_number': 'header', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__test_endpoint_enums_length_one + ) + + def __test_endpoint_parameters( + self, + number, + double, + pattern_without_delimiter, + byte, + **kwargs + ): + """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, async_req=True) + >>> result = thread.get() + + Args: + number (float): None + double (float): None + pattern_without_delimiter (str): None + byte (str): None + + Keyword Args: + integer (int): None. [optional] + int32 (int): None. [optional] + int64 (int): None. [optional] + float (float): None. [optional] + string (str): None. [optional] + binary (file_type): None. [optional] + date (date): None. [optional] + date_time (datetime): None. [optional] + password (str): None. [optional] + param_callback (str): None. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['number'] = \ + number + kwargs['double'] = \ + double + kwargs['pattern_without_delimiter'] = \ + pattern_without_delimiter + kwargs['byte'] = \ + byte + return self.call_with_http_info(**kwargs) + + self.test_endpoint_parameters = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'http_basic_test' + ], + 'endpoint_path': '/fake', + 'operation_id': 'test_endpoint_parameters', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'byte', + 'integer', + 'int32', + 'int64', + 'float', + 'string', + 'binary', + 'date', + 'date_time', + 'password', + 'param_callback', + ], + 'required': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'byte', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'integer', + 'int32', + 'float', + 'string', + 'password', + ] + }, + root_map={ + 'validations': { + ('number',): { + + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + }, + ('double',): { + + 'inclusive_maximum': 123.4, + 'inclusive_minimum': 67.8, + }, + ('pattern_without_delimiter',): { + + 'regex': { + 'pattern': r'^[A-Z].*', # noqa: E501 + }, + }, + ('integer',): { + + 'inclusive_maximum': 100, + 'inclusive_minimum': 10, + }, + ('int32',): { + + 'inclusive_maximum': 200, + 'inclusive_minimum': 20, + }, + ('float',): { + + 'inclusive_maximum': 987.6, + }, + ('string',): { + + 'regex': { + 'pattern': r'[a-z]', # noqa: E501 + 'flags': (re.IGNORECASE) + }, + }, + ('password',): { + 'max_length': 64, + 'min_length': 10, + }, + }, + 'allowed_values': { + }, + 'openapi_types': { + 'number': + (float,), + 'double': + (float,), + 'pattern_without_delimiter': + (str,), + 'byte': + (str,), + 'integer': + (int,), + 'int32': + (int,), + 'int64': + (int,), + 'float': + (float,), + 'string': + (str,), + 'binary': + (file_type,), + 'date': + (date,), + 'date_time': + (datetime,), + 'password': + (str,), + 'param_callback': + (str,), + }, + 'attribute_map': { + 'number': 'number', + 'double': 'double', + 'pattern_without_delimiter': 'pattern_without_delimiter', + 'byte': 'byte', + 'integer': 'integer', + 'int32': 'int32', + 'int64': 'int64', + 'float': 'float', + 'string': 'string', + 'binary': 'binary', + 'date': 'date', + 'date_time': 'dateTime', + 'password': 'password', + 'param_callback': 'callback', + }, + 'location_map': { + 'number': 'form', + 'double': 'form', + 'pattern_without_delimiter': 'form', + 'byte': 'form', + 'integer': 'form', + 'int32': 'form', + 'int64': 'form', + 'float': 'form', + 'string': 'form', + 'binary': 'form', + 'date': 'form', + 'date_time': 'form', + 'password': 'form', + 'param_callback': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_endpoint_parameters + ) + + def __test_enum_parameters( + self, + **kwargs + ): + """To test enum parameters # noqa: E501 + + To test enum parameters # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_enum_parameters(async_req=True) + >>> result = thread.get() + + + Keyword Args: + enum_header_string_array ([str]): Header parameter enum test (string array). [optional] + enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" + enum_query_string_array ([str]): Query parameter enum test (string array). [optional] + enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" + enum_query_integer (int): Query parameter enum test (double). [optional] + enum_query_double (float): Query parameter enum test (double). [optional] + enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of "$" + enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.test_enum_parameters = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_enum_parameters', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'enum_header_string_array', + 'enum_header_string', + 'enum_query_string_array', + 'enum_query_string', + 'enum_query_integer', + 'enum_query_double', + 'enum_form_string_array', + 'enum_form_string', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + 'enum_header_string_array', + 'enum_header_string', + 'enum_query_string_array', + 'enum_query_string', + 'enum_query_integer', + 'enum_query_double', + 'enum_form_string_array', + 'enum_form_string', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('enum_header_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_header_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + ('enum_query_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_query_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + ('enum_query_integer',): { + + "1": 1, + "-2": -2 + }, + ('enum_query_double',): { + + "1.1": 1.1, + "-1.2": -1.2 + }, + ('enum_form_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_form_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + }, + 'openapi_types': { + 'enum_header_string_array': + ([str],), + 'enum_header_string': + (str,), + 'enum_query_string_array': + ([str],), + 'enum_query_string': + (str,), + 'enum_query_integer': + (int,), + 'enum_query_double': + (float,), + 'enum_form_string_array': + ([str],), + 'enum_form_string': + (str,), + }, + 'attribute_map': { + 'enum_header_string_array': 'enum_header_string_array', + 'enum_header_string': 'enum_header_string', + 'enum_query_string_array': 'enum_query_string_array', + 'enum_query_string': 'enum_query_string', + 'enum_query_integer': 'enum_query_integer', + 'enum_query_double': 'enum_query_double', + 'enum_form_string_array': 'enum_form_string_array', + 'enum_form_string': 'enum_form_string', + }, + 'location_map': { + 'enum_header_string_array': 'header', + 'enum_header_string': 'header', + 'enum_query_string_array': 'query', + 'enum_query_string': 'query', + 'enum_query_integer': 'query', + 'enum_query_double': 'query', + 'enum_form_string_array': 'form', + 'enum_form_string': 'form', + }, + 'collection_format_map': { + 'enum_header_string_array': 'csv', + 'enum_query_string_array': 'csv', + 'enum_form_string_array': 'csv', + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_enum_parameters + ) + + def __test_group_parameters( + self, + required_string_group, + required_boolean_group, + required_int64_group, + **kwargs + ): + """Fake endpoint to test group parameters (optional) # noqa: E501 + + Fake endpoint to test group parameters (optional) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, async_req=True) + >>> result = thread.get() + + Args: + required_string_group (int): Required String in group parameters + required_boolean_group (bool): Required Boolean in group parameters + required_int64_group (int): Required Integer in group parameters + + Keyword Args: + string_group (int): String in group parameters. [optional] + boolean_group (bool): Boolean in group parameters. [optional] + int64_group (int): Integer in group parameters. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['required_string_group'] = \ + required_string_group + kwargs['required_boolean_group'] = \ + required_boolean_group + kwargs['required_int64_group'] = \ + required_int64_group + return self.call_with_http_info(**kwargs) + + self.test_group_parameters = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_group_parameters', + 'http_method': 'DELETE', + 'servers': None, + }, + params_map={ + 'all': [ + 'required_string_group', + 'required_boolean_group', + 'required_int64_group', + 'string_group', + 'boolean_group', + 'int64_group', + ], + 'required': [ + 'required_string_group', + 'required_boolean_group', + 'required_int64_group', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'required_string_group': + (int,), + 'required_boolean_group': + (bool,), + 'required_int64_group': + (int,), + 'string_group': + (int,), + 'boolean_group': + (bool,), + 'int64_group': + (int,), + }, + 'attribute_map': { + 'required_string_group': 'required_string_group', + 'required_boolean_group': 'required_boolean_group', + 'required_int64_group': 'required_int64_group', + 'string_group': 'string_group', + 'boolean_group': 'boolean_group', + 'int64_group': 'int64_group', + }, + 'location_map': { + 'required_string_group': 'query', + 'required_boolean_group': 'header', + 'required_int64_group': 'query', + 'string_group': 'query', + 'boolean_group': 'header', + 'int64_group': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__test_group_parameters + ) + + def __test_inline_additional_properties( + self, + param, + **kwargs + ): + """test inline additionalProperties # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_inline_additional_properties(param, async_req=True) + >>> result = thread.get() + + Args: + param ({str: (str,)}): request body + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['param'] = \ + param + return self.call_with_http_info(**kwargs) + + self.test_inline_additional_properties = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/inline-additionalProperties', + 'operation_id': 'test_inline_additional_properties', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'param', + ], + 'required': [ + 'param', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'param': + ({str: (str,)},), + }, + 'attribute_map': { + }, + 'location_map': { + 'param': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_inline_additional_properties + ) + + def __test_json_form_data( + self, + param, + param2, + **kwargs + ): + """test json serialization of form data # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_json_form_data(param, param2, async_req=True) + >>> result = thread.get() + + Args: + param (str): field1 + param2 (str): field2 + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['param'] = \ + param + kwargs['param2'] = \ + param2 + return self.call_with_http_info(**kwargs) + + self.test_json_form_data = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/jsonFormData', + 'operation_id': 'test_json_form_data', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'param', + 'param2', + ], + 'required': [ + 'param', + 'param2', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'param': + (str,), + 'param2': + (str,), + }, + 'attribute_map': { + 'param': 'param', + 'param2': 'param2', + }, + 'location_map': { + 'param': 'form', + 'param2': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_json_form_data + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags_123_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags_123_api.py new file mode 100644 index 00000000000..1d1afc214c1 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags_123_api.py @@ -0,0 +1,157 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.client import Client + + +class FakeClassnameTags123Api(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __test_classname( + self, + body, + **kwargs + ): + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_classname(body, async_req=True) + >>> result = thread.get() + + Args: + body (Client): client model + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.test_classname = _Endpoint( + settings={ + 'response_type': (Client,), + 'auth': [ + 'api_key_query' + ], + 'endpoint_path': '/fake_classname_test', + 'operation_id': 'test_classname', + 'http_method': 'PATCH', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Client,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_classname + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/pet_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/pet_api.py new file mode 100644 index 00000000000..2989ca8d4ab --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/pet_api.py @@ -0,0 +1,1170 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.api_response import ApiResponse +from petstore_api.model.pet import Pet + + +class PetApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __add_pet( + self, + body, + **kwargs + ): + """Add a new pet to the store # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_pet(body, async_req=True) + >>> result = thread.get() + + Args: + body (Pet): Pet object that needs to be added to the store + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.add_pet = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet', + 'operation_id': 'add_pet', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Pet,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json', + 'application/xml' + ] + }, + api_client=api_client, + callable=__add_pet + ) + + def __delete_pet( + self, + pet_id, + **kwargs + ): + """Deletes a pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_pet(pet_id, async_req=True) + >>> result = thread.get() + + Args: + pet_id (int): Pet id to delete + + Keyword Args: + api_key (str): [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['pet_id'] = \ + pet_id + return self.call_with_http_info(**kwargs) + + self.delete_pet = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'delete_pet', + 'http_method': 'DELETE', + 'servers': None, + }, + params_map={ + 'all': [ + 'pet_id', + 'api_key', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': + (int,), + 'api_key': + (str,), + }, + 'attribute_map': { + 'pet_id': 'petId', + 'api_key': 'api_key', + }, + 'location_map': { + 'pet_id': 'path', + 'api_key': 'header', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_pet + ) + + def __find_pets_by_status( + self, + status, + **kwargs + ): + """Finds Pets by status # noqa: E501 + + Multiple status values can be provided with comma separated strings # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_status(status, async_req=True) + >>> result = thread.get() + + Args: + status ([str]): Status values that need to be considered for filter + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + [Pet] + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['status'] = \ + status + return self.call_with_http_info(**kwargs) + + self.find_pets_by_status = _Endpoint( + settings={ + 'response_type': ([Pet],), + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/findByStatus', + 'operation_id': 'find_pets_by_status', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'status', + ], + 'required': [ + 'status', + ], + 'nullable': [ + ], + 'enum': [ + 'status', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('status',): { + + "AVAILABLE": "available", + "PENDING": "pending", + "SOLD": "sold" + }, + }, + 'openapi_types': { + 'status': + ([str],), + }, + 'attribute_map': { + 'status': 'status', + }, + 'location_map': { + 'status': 'query', + }, + 'collection_format_map': { + 'status': 'csv', + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__find_pets_by_status + ) + + def __find_pets_by_tags( + self, + tags, + **kwargs + ): + """Finds Pets by tags # noqa: E501 + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_tags(tags, async_req=True) + >>> result = thread.get() + + Args: + tags ([str]): Tags to filter by + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + [Pet] + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['tags'] = \ + tags + return self.call_with_http_info(**kwargs) + + self.find_pets_by_tags = _Endpoint( + settings={ + 'response_type': ([Pet],), + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/findByTags', + 'operation_id': 'find_pets_by_tags', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'tags', + ], + 'required': [ + 'tags', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'tags': + ([str],), + }, + 'attribute_map': { + 'tags': 'tags', + }, + 'location_map': { + 'tags': 'query', + }, + 'collection_format_map': { + 'tags': 'csv', + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__find_pets_by_tags + ) + + def __get_pet_by_id( + self, + pet_id, + **kwargs + ): + """Find pet by ID # noqa: E501 + + Returns a single pet # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pet_by_id(pet_id, async_req=True) + >>> result = thread.get() + + Args: + pet_id (int): ID of pet to return + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Pet + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['pet_id'] = \ + pet_id + return self.call_with_http_info(**kwargs) + + self.get_pet_by_id = _Endpoint( + settings={ + 'response_type': (Pet,), + 'auth': [ + 'api_key' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'get_pet_by_id', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'pet_id', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': + (int,), + }, + 'attribute_map': { + 'pet_id': 'petId', + }, + 'location_map': { + 'pet_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_pet_by_id + ) + + def __update_pet( + self, + body, + **kwargs + ): + """Update an existing pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet(body, async_req=True) + >>> result = thread.get() + + Args: + body (Pet): Pet object that needs to be added to the store + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.update_pet = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet', + 'operation_id': 'update_pet', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Pet,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json', + 'application/xml' + ] + }, + api_client=api_client, + callable=__update_pet + ) + + def __update_pet_with_form( + self, + pet_id, + **kwargs + ): + """Updates a pet in the store with form data # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet_with_form(pet_id, async_req=True) + >>> result = thread.get() + + Args: + pet_id (int): ID of pet that needs to be updated + + Keyword Args: + name (str): Updated name of the pet. [optional] + status (str): Updated status of the pet. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['pet_id'] = \ + pet_id + return self.call_with_http_info(**kwargs) + + self.update_pet_with_form = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'update_pet_with_form', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'pet_id', + 'name', + 'status', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': + (int,), + 'name': + (str,), + 'status': + (str,), + }, + 'attribute_map': { + 'pet_id': 'petId', + 'name': 'name', + 'status': 'status', + }, + 'location_map': { + 'pet_id': 'path', + 'name': 'form', + 'status': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__update_pet_with_form + ) + + def __upload_file( + self, + pet_id, + **kwargs + ): + """uploads an image # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file(pet_id, async_req=True) + >>> result = thread.get() + + Args: + pet_id (int): ID of pet to update + + Keyword Args: + additional_metadata (str): Additional data to pass to server. [optional] + file (file_type): file to upload. [optional] + files ([file_type]): files to upload. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + ApiResponse + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['pet_id'] = \ + pet_id + return self.call_with_http_info(**kwargs) + + self.upload_file = _Endpoint( + settings={ + 'response_type': (ApiResponse,), + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}/uploadImage', + 'operation_id': 'upload_file', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'pet_id', + 'additional_metadata', + 'file', + 'files', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': + (int,), + 'additional_metadata': + (str,), + 'file': + (file_type,), + 'files': + ([file_type],), + }, + 'attribute_map': { + 'pet_id': 'petId', + 'additional_metadata': 'additionalMetadata', + 'file': 'file', + 'files': 'files', + }, + 'location_map': { + 'pet_id': 'path', + 'additional_metadata': 'form', + 'file': 'form', + 'files': 'form', + }, + 'collection_format_map': { + 'files': 'csv', + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'multipart/form-data' + ] + }, + api_client=api_client, + callable=__upload_file + ) + + def __upload_file_with_required_file( + self, + pet_id, + required_file, + **kwargs + ): + """uploads an image (required) # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file_with_required_file(pet_id, required_file, async_req=True) + >>> result = thread.get() + + Args: + pet_id (int): ID of pet to update + required_file (file_type): file to upload + + Keyword Args: + additional_metadata (str): Additional data to pass to server. [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + ApiResponse + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['pet_id'] = \ + pet_id + kwargs['required_file'] = \ + required_file + return self.call_with_http_info(**kwargs) + + self.upload_file_with_required_file = _Endpoint( + settings={ + 'response_type': (ApiResponse,), + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/fake/{petId}/uploadImageWithRequiredFile', + 'operation_id': 'upload_file_with_required_file', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'pet_id', + 'required_file', + 'additional_metadata', + ], + 'required': [ + 'pet_id', + 'required_file', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': + (int,), + 'required_file': + (file_type,), + 'additional_metadata': + (str,), + }, + 'attribute_map': { + 'pet_id': 'petId', + 'required_file': 'requiredFile', + 'additional_metadata': 'additionalMetadata', + }, + 'location_map': { + 'pet_id': 'path', + 'required_file': 'form', + 'additional_metadata': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'multipart/form-data' + ] + }, + api_client=api_client, + callable=__upload_file_with_required_file + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/store_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/store_api.py new file mode 100644 index 00000000000..c30ca943b2d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/store_api.py @@ -0,0 +1,499 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.order import Order + + +class StoreApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __delete_order( + self, + order_id, + **kwargs + ): + """Delete purchase order by ID # noqa: E501 + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_order(order_id, async_req=True) + >>> result = thread.get() + + Args: + order_id (str): ID of the order that needs to be deleted + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['order_id'] = \ + order_id + return self.call_with_http_info(**kwargs) + + self.delete_order = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/store/order/{order_id}', + 'operation_id': 'delete_order', + 'http_method': 'DELETE', + 'servers': None, + }, + params_map={ + 'all': [ + 'order_id', + ], + 'required': [ + 'order_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'order_id': + (str,), + }, + 'attribute_map': { + 'order_id': 'order_id', + }, + 'location_map': { + 'order_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_order + ) + + def __get_inventory( + self, + **kwargs + ): + """Returns pet inventories by status # noqa: E501 + + Returns a map of status codes to quantities # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inventory(async_req=True) + >>> result = thread.get() + + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + {str: (int,)} + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.get_inventory = _Endpoint( + settings={ + 'response_type': ({str: (int,)},), + 'auth': [ + 'api_key' + ], + 'endpoint_path': '/store/inventory', + 'operation_id': 'get_inventory', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_inventory + ) + + def __get_order_by_id( + self, + order_id, + **kwargs + ): + """Find purchase order by ID # noqa: E501 + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_order_by_id(order_id, async_req=True) + >>> result = thread.get() + + Args: + order_id (int): ID of pet that needs to be fetched + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Order + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['order_id'] = \ + order_id + return self.call_with_http_info(**kwargs) + + self.get_order_by_id = _Endpoint( + settings={ + 'response_type': (Order,), + 'auth': [], + 'endpoint_path': '/store/order/{order_id}', + 'operation_id': 'get_order_by_id', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'order_id', + ], + 'required': [ + 'order_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + 'order_id', + ] + }, + root_map={ + 'validations': { + ('order_id',): { + + 'inclusive_maximum': 5, + 'inclusive_minimum': 1, + }, + }, + 'allowed_values': { + }, + 'openapi_types': { + 'order_id': + (int,), + }, + 'attribute_map': { + 'order_id': 'order_id', + }, + 'location_map': { + 'order_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_order_by_id + ) + + def __place_order( + self, + body, + **kwargs + ): + """Place an order for a pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.place_order(body, async_req=True) + >>> result = thread.get() + + Args: + body (Order): order placed for purchasing the pet + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Order + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.place_order = _Endpoint( + settings={ + 'response_type': (Order,), + 'auth': [], + 'endpoint_path': '/store/order', + 'operation_id': 'place_order', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (Order,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__place_order + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/user_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/user_api.py new file mode 100644 index 00000000000..a5ef0d5c309 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/user_api.py @@ -0,0 +1,962 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.api_client import ApiClient, Endpoint as _Endpoint +from petstore_api.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +from petstore_api.model.user import User + + +class UserApi(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def __create_user( + self, + body, + **kwargs + ): + """Create user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_user(body, async_req=True) + >>> result = thread.get() + + Args: + body (User): Created user object + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.create_user = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user', + 'operation_id': 'create_user', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + (User,), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_user + ) + + def __create_users_with_array_input( + self, + body, + **kwargs + ): + """Creates list of users with given input array # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_array_input(body, async_req=True) + >>> result = thread.get() + + Args: + body ([User]): List of user object + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.create_users_with_array_input = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/createWithArray', + 'operation_id': 'create_users_with_array_input', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + ([User],), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_users_with_array_input + ) + + def __create_users_with_list_input( + self, + body, + **kwargs + ): + """Creates list of users with given input array # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_list_input(body, async_req=True) + >>> result = thread.get() + + Args: + body ([User]): List of user object + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.create_users_with_list_input = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/createWithList', + 'operation_id': 'create_users_with_list_input', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': + ([User],), + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_users_with_list_input + ) + + def __delete_user( + self, + username, + **kwargs + ): + """Delete user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_user(username, async_req=True) + >>> result = thread.get() + + Args: + username (str): The name that needs to be deleted + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['username'] = \ + username + return self.call_with_http_info(**kwargs) + + self.delete_user = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'delete_user', + 'http_method': 'DELETE', + 'servers': None, + }, + params_map={ + 'all': [ + 'username', + ], + 'required': [ + 'username', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': + (str,), + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_user + ) + + def __get_user_by_name( + self, + username, + **kwargs + ): + """Get user by user name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_user_by_name(username, async_req=True) + >>> result = thread.get() + + Args: + username (str): The name that needs to be fetched. Use user1 for testing. + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + User + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['username'] = \ + username + return self.call_with_http_info(**kwargs) + + self.get_user_by_name = _Endpoint( + settings={ + 'response_type': (User,), + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'get_user_by_name', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'username', + ], + 'required': [ + 'username', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': + (str,), + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_user_by_name + ) + + def __login_user( + self, + username, + password, + **kwargs + ): + """Logs user into the system # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.login_user(username, password, async_req=True) + >>> result = thread.get() + + Args: + username (str): The user name for login + password (str): The password for login in clear text + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + str + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['username'] = \ + username + kwargs['password'] = \ + password + return self.call_with_http_info(**kwargs) + + self.login_user = _Endpoint( + settings={ + 'response_type': (str,), + 'auth': [], + 'endpoint_path': '/user/login', + 'operation_id': 'login_user', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'username', + 'password', + ], + 'required': [ + 'username', + 'password', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': + (str,), + 'password': + (str,), + }, + 'attribute_map': { + 'username': 'username', + 'password': 'password', + }, + 'location_map': { + 'username': 'query', + 'password': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__login_user + ) + + def __logout_user( + self, + **kwargs + ): + """Logs out current logged in user session # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.logout_user(async_req=True) + >>> result = thread.get() + + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.logout_user = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/logout', + 'operation_id': 'logout_user', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__logout_user + ) + + def __update_user( + self, + username, + body, + **kwargs + ): + """Updated user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_user(username, body, async_req=True) + >>> result = thread.get() + + Args: + username (str): name that need to be deleted + body (User): Updated user object + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['username'] = \ + username + kwargs['body'] = \ + body + return self.call_with_http_info(**kwargs) + + self.update_user = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'update_user', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'username', + 'body', + ], + 'required': [ + 'username', + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': + (str,), + 'body': + (User,), + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__update_user + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py new file mode 100644 index 00000000000..a43e4ace242 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py @@ -0,0 +1,849 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import json +import atexit +import mimetypes +from multiprocessing.pool import ThreadPool +import io +import os +import re +import typing +from urllib.parse import quote +from urllib3.fields import RequestField + + +from petstore_api import rest +from petstore_api.configuration import Configuration +from petstore_api.exceptions import ApiTypeError, ApiValueError, ApiException +from petstore_api.model_utils import ( + ModelNormal, + ModelSimple, + ModelComposed, + check_allowed_values, + check_validations, + date, + datetime, + deserialize_file, + file_type, + model_to_dict, + none_type, + validate_and_convert_types +) + + +class ApiClient(object): + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): + if configuration is None: + configuration = Configuration.get_default_copy() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + def __call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + if header_params['Content-Type'].startswith("multipart"): + post_params = self.parameters_to_multipart(post_params, + (dict) ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # auth setting + self.update_params_for_auth(header_params, query_params, + auth_settings, resource_path, method, body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + try: + # perform request and return response + response_data = self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = response_data + + if not _preload_content: + return (return_data) + return return_data + + # deserialize response data + if response_type: + if response_type != (file_type,): + encoding = "utf-8" + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + if match: + encoding = match.group(1) + response_data.data = response_data.data.decode(encoding) + + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) + else: + return_data = None + + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) + + def parameters_to_multipart(self, params, collection_types): + """Get parameters as list of tuples, formatting as json if value is collection_types + + :param params: Parameters as list of two-tuples + :param dict collection_types: Parameter collection types + :return: Parameters as list of tuple or urllib3.fields.RequestField + """ + new_params = [] + if collection_types is None: + collection_types = (dict) + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, collection_types): # v is instance of collection_type, formatting as application/json + v = json.dumps(v, ensure_ascii=False).encode("utf-8") + field = RequestField(k, v) + field.make_multipart(content_type="application/json; charset=utf-8") + new_params.append(field) + else: + new_params.append((k, v)) + return new_params + + @classmethod + def sanitize_for_serialization(cls, obj): + """Prepares data for transmission before it is sent with the rest client + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + If obj is io.IOBase, return the bytes + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if isinstance(obj, (ModelNormal, ModelComposed)): + return { + key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() + } + elif isinstance(obj, io.IOBase): + return cls.get_file_data_and_close_file(obj) + elif isinstance(obj, (str, int, float, none_type, bool)): + return obj + elif isinstance(obj, (datetime, date)): + return obj.isoformat() + elif isinstance(obj, ModelSimple): + return cls.sanitize_for_serialization(obj.value) + elif isinstance(obj, (list, tuple)): + return [cls.sanitize_for_serialization(item) for item in obj] + if isinstance(obj, dict): + return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + def deserialize(self, response, response_type, _check_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({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. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == (file_type,): + content_disposition = response.getheader("Content-Disposition") + return deserialize_file(response.data, self.configuration, + content_disposition=content_disposition) + + # fetch data from response object + try: + received_data = json.loads(response.data) + except ValueError: + received_data = response.data + + # store our data under the key of 'received_data' so users have some + # context if they are deserializing a string and the data type is wrong + deserialized_data = validate_and_convert_types( + received_data, + response_type, + ['received_data'], + True, + _check_type, + configuration=self.configuration + ) + return deserialized_data + + def call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :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. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _check_type) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + @staticmethod + def get_file_data_and_close_file(file_instance: io.IOBase) -> bytes: + file_data = file_instance.read() + file_instance.close() + return file_data + + def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): + """Builds form parameters. + + :param files: None or a dict with key=param_name and + value is a list of open file objects + :return: List of tuples of form parameters with file data + """ + if files is None: + return [] + + params = [] + for param_name, file_instances in files.items(): + if file_instances is None: + # if the file field is nullable, skip None values + continue + for file_instance in file_instances: + if file_instance is None: + # if the file field is nullable, skip None values + continue + if file_instance.closed is True: + raise ApiValueError( + "Cannot read a closed file. The passed in file_type " + "for %s must be open." % param_name + ) + filename = os.path.basename(file_instance.name) + filedata = self.get_file_data_and_close_file(file_instance) + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([param_name, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings, + resource_path, method, body): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :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 _encoder.default(). + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + settings (dict): see below key value pairs + 'response_type' (tuple/None): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called + """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only', + '_check_input_type', + '_check_return_type' + ]) + self.params_map['nullable'].extend(['_request_timeout']) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + extra_types = { + 'async_req': (bool,), + '_host_index': (none_type, int), + '_preload_content': (bool,), + '_request_timeout': (none_type, int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) + } + self.openapi_types.update(extra_types) + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param] + ) + + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param], + configuration=self.api_client.configuration + ) + + if kwargs['_check_input_type'] is False: + return + + for key, value in kwargs.items(): + fixed_val = validate_and_convert_types( + value, + self.openapi_types[key], + [key], + False, + kwargs['_check_input_type'], + configuration=self.api_client.configuration + ) + kwargs[key] = fixed_val + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in kwargs.items(): + param_location = self.location_map.get(param_name) + if param_location is None: + continue + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): + # param_value is already a list + params['file'][param_name] = param_value + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + + api_instance = AnotherFakeApi() + api_instance.call_123_test_special_tags # this is an instance of the class Endpoint + api_instance.call_123_test_special_tags() # this invokes api_instance.call_123_test_special_tags.__call__() + which then invokes the callable functions stored in that endpoint at + api_instance.call_123_test_special_tags.callable or self.callable in this class + + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + try: + index = self.api_client.configuration.server_operation_index.get( + self.settings['operation_id'], self.api_client.configuration.server_index + ) if kwargs['_host_index'] is None else kwargs['_host_index'] + server_variables = self.api_client.configuration.server_operation_variables.get( + self.settings['operation_id'], self.api_client.configuration.server_variables + ) + _host = self.api_client.configuration.get_host_from_settings( + index, variables=server_variables, servers=self.settings['servers'] + ) + except IndexError: + if self.settings['servers']: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + _host = None + + for key, value in kwargs.items(): + if key not in self.params_map['all']: + raise ApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + # only throw this nullable ApiValueError if _check_input_type + # is False, if _check_input_type==True we catch this case + # in self.__validate_inputs + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) + + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) + + self.__validate_inputs(kwargs) + + params = self.__gather_params(kwargs) + + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) + + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list + + return self.api_client.call_api( + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], + _host=_host, + collection_formats=params['collection_format']) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/apis/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/apis/__init__.py new file mode 100644 index 00000000000..e4c52458a0c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/apis/__init__.py @@ -0,0 +1,22 @@ + +# flake8: noqa + +# Import all APIs into this package. +# If you have many APIs here with many many models used in each API this may +# raise a `RecursionError`. +# In order to avoid this, import only the API that you directly need like: +# +# from .api.another_fake_api import AnotherFakeApi +# +# or import this package, but before doing it, use: +# +# import sys +# sys.setrecursionlimit(n) + +# Import APIs into API package: +from petstore_api.api.another_fake_api import AnotherFakeApi +from petstore_api.api.fake_api import FakeApi +from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api +from petstore_api.api.pet_api import PetApi +from petstore_api.api.store_api import StoreApi +from petstore_api.api.user_api import UserApi diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/configuration.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/configuration.py new file mode 100644 index 00000000000..ccd984b7f5f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/configuration.py @@ -0,0 +1,511 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +from http import client as http_client +from petstore_api.exceptions import ApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format + + :Example: + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = petstore_api.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 + + HTTP Basic Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: basic + + Configure API client with HTTP basic authentication: + +conf = petstore_api.Configuration( + username='the-user', + password='the-password', +) + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + access_token=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ): + """Constructor + """ + self._base_path = "http://petstore.swagger.io:80/v2" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.access_token = access_token + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("petstore_api") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + if 'api_key' in self.api_key: + auth['api_key'] = { + 'type': 'api_key', + 'in': 'header', + 'key': 'api_key', + 'value': self.get_api_key_with_prefix( + 'api_key', + ), + } + if 'api_key_query' in self.api_key: + auth['api_key_query'] = { + 'type': 'api_key', + 'in': 'query', + 'key': 'api_key_query', + 'value': self.get_api_key_with_prefix( + 'api_key_query', + ), + } + if self.username is not None and self.password is not None: + auth['http_basic_test'] = { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + } + if self.access_token is not None: + auth['petstore_auth'] = { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 1.0.0\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "http://petstore.swagger.io:80/v2", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/exceptions.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/exceptions.py new file mode 100644 index 00000000000..51527f60611 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/exceptions.py @@ -0,0 +1,159 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ServiceException, self).__init__(status, reason, http_resp) + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/__init__.py new file mode 100644 index 00000000000..cfe32b78492 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/__init__.py @@ -0,0 +1,5 @@ +# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from {{packageName}.models import ModelA, ModelB diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_any_type.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_any_type.py new file mode 100644 index 00000000000..7239795cf4a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_any_type.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesAnyType(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesAnyType - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_array.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_array.py new file mode 100644 index 00000000000..7d9403758a0 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_array.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesArray(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return ([bool, date, datetime, dict, float, int, list, str, none_type],) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesArray - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_boolean.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_boolean.py new file mode 100644 index 00000000000..ca129b766ec --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_boolean.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesBoolean(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesBoolean - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_class.py new file mode 100644 index 00000000000..292f467aaa8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_class.py @@ -0,0 +1,196 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesClass(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'map_string': ({str: (str,)},), # noqa: E501 + 'map_number': ({str: (float,)},), # noqa: E501 + 'map_integer': ({str: (int,)},), # noqa: E501 + 'map_boolean': ({str: (bool,)},), # noqa: E501 + 'map_array_integer': ({str: ([int],)},), # noqa: E501 + 'map_array_anytype': ({str: ([bool, date, datetime, dict, float, int, list, str, none_type],)},), # noqa: E501 + 'map_map_string': ({str: ({str: (str,)},)},), # noqa: E501 + 'map_map_anytype': ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)},), # noqa: E501 + 'anytype_1': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 + 'anytype_2': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 + 'anytype_3': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'map_string': 'map_string', # noqa: E501 + 'map_number': 'map_number', # noqa: E501 + 'map_integer': 'map_integer', # noqa: E501 + 'map_boolean': 'map_boolean', # noqa: E501 + 'map_array_integer': 'map_array_integer', # noqa: E501 + 'map_array_anytype': 'map_array_anytype', # noqa: E501 + 'map_map_string': 'map_map_string', # noqa: E501 + 'map_map_anytype': 'map_map_anytype', # noqa: E501 + 'anytype_1': 'anytype_1', # noqa: E501 + 'anytype_2': 'anytype_2', # noqa: E501 + 'anytype_3': 'anytype_3', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesClass - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + map_string ({str: (str,)}): [optional] # noqa: E501 + map_number ({str: (float,)}): [optional] # noqa: E501 + map_integer ({str: (int,)}): [optional] # noqa: E501 + map_boolean ({str: (bool,)}): [optional] # noqa: E501 + map_array_integer ({str: ([int],)}): [optional] # noqa: E501 + map_array_anytype ({str: ([bool, date, datetime, dict, float, int, list, str, none_type],)}): [optional] # noqa: E501 + map_map_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 + map_map_anytype ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},)}): [optional] # noqa: E501 + anytype_1 (bool, date, datetime, dict, float, int, list, str, none_type): [optional] # noqa: E501 + anytype_2 (bool, date, datetime, dict, float, int, list, str, none_type): no type is set for this. [optional] # noqa: E501 + anytype_3 (bool, date, datetime, dict, float, int, list, str, none_type): because of a bug in swagger-parser, this should have values {str: (str, int, float...)} but instead we get any type. See https://github.com/swagger-api/swagger-parser/issues/1378. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_integer.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_integer.py new file mode 100644 index 00000000000..87d78bf3600 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_integer.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesInteger(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (int,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesInteger - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py new file mode 100644 index 00000000000..b10bd036ff3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesNumber(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (float,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesNumber - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_object.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_object.py new file mode 100644 index 00000000000..000653f13a7 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_object.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesObject(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return ({str: (bool, date, datetime, dict, float, int, list, str, none_type,)},) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesObject - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_string.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_string.py new file mode 100644 index 00000000000..7f1f94aa6b6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_string.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class AdditionalPropertiesString(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (str,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesString - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal.py new file mode 100644 index 00000000000..a3d48b6ea97 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal.py @@ -0,0 +1,185 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.cat import Cat + from petstore_api.model.dog import Dog + globals()['Cat'] = Cat + globals()['Dog'] = Dog + + +class Animal(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'class_name': (str,), # noqa: E501 + 'color': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + lazy_import() + val = { + 'Cat': Cat, + 'Dog': Dog, + } + if not val: + return None + return {'class_name': val} + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, class_name, *args, **kwargs): # noqa: E501 + """Animal - a model defined in OpenAPI + + Args: + class_name (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.class_name = class_name + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal_farm.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal_farm.py new file mode 100644 index 00000000000..838b18a1297 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/animal_farm.py @@ -0,0 +1,184 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.animal import Animal + globals()['Animal'] = Animal + + +class AnimalFarm(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'value': ([Animal],), + } + + @cached_property + def discriminator(): + return None + + + attribute_map = {} + + _composed_schemas = None + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): + """AnimalFarm - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([Animal]): # noqa: E501 + + Keyword Args: + value ([Animal]): # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/api_response.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/api_response.py new file mode 100644 index 00000000000..01e2175b800 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/api_response.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ApiResponse(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'code': (int,), # noqa: E501 + 'type': (str,), # noqa: E501 + 'message': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'code': 'code', # noqa: E501 + 'type': 'type', # noqa: E501 + 'message': 'message', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ApiResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + code (int): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 + message (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_array_of_number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_array_of_number_only.py new file mode 100644 index 00000000000..008b74dd42a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_array_of_number_only.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ArrayOfArrayOfNumberOnly(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'array_array_number': ([[float]],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_array_number': 'ArrayArrayNumber', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ArrayOfArrayOfNumberOnly - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_array_number ([[float]]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_number_only.py new file mode 100644 index 00000000000..f2e080bc258 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_of_number_only.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ArrayOfNumberOnly(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'array_number': ([float],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_number': 'ArrayNumber', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ArrayOfNumberOnly - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_number ([float]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_test.py new file mode 100644 index 00000000000..ac42b07b93c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/array_test.py @@ -0,0 +1,177 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.read_only_first import ReadOnlyFirst + globals()['ReadOnlyFirst'] = ReadOnlyFirst + + +class ArrayTest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'array_of_string': ([str],), # noqa: E501 + 'array_array_of_integer': ([[int]],), # noqa: E501 + 'array_array_of_model': ([[ReadOnlyFirst]],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_of_string': 'array_of_string', # noqa: E501 + 'array_array_of_integer': 'array_array_of_integer', # noqa: E501 + 'array_array_of_model': 'array_array_of_model', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ArrayTest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_of_string ([str]): [optional] # noqa: E501 + array_array_of_integer ([[int]]): [optional] # noqa: E501 + array_array_of_model ([[ReadOnlyFirst]]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/capitalization.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/capitalization.py new file mode 100644 index 00000000000..710c17e51a5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/capitalization.py @@ -0,0 +1,181 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Capitalization(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'small_camel': (str,), # noqa: E501 + 'capital_camel': (str,), # noqa: E501 + 'small_snake': (str,), # noqa: E501 + 'capital_snake': (str,), # noqa: E501 + 'sca_eth_flow_points': (str,), # noqa: E501 + 'att_name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'small_camel': 'smallCamel', # noqa: E501 + 'capital_camel': 'CapitalCamel', # noqa: E501 + 'small_snake': 'small_Snake', # noqa: E501 + 'capital_snake': 'Capital_Snake', # noqa: E501 + 'sca_eth_flow_points': 'SCA_ETH_Flow_Points', # noqa: E501 + 'att_name': 'ATT_NAME', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Capitalization - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + small_camel (str): [optional] # noqa: E501 + capital_camel (str): [optional] # noqa: E501 + small_snake (str): [optional] # noqa: E501 + capital_snake (str): [optional] # noqa: E501 + sca_eth_flow_points (str): [optional] # noqa: E501 + att_name (str): Name of the pet . [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat.py new file mode 100644 index 00000000000..fd8d4bc7179 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat.py @@ -0,0 +1,218 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.animal import Animal + from petstore_api.model.cat_all_of import CatAllOf + globals()['Animal'] = Animal + globals()['CatAllOf'] = CatAllOf + + +class Cat(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'class_name': (str,), # noqa: E501 + 'declawed': (bool,), # noqa: E501 + 'color': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + } + if not val: + return None + return {'class_name': val} + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'declawed': 'declawed', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Cat - a model defined in OpenAPI + + Keyword Args: + class_name (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + declawed (bool): [optional] # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + Animal, + CatAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat_all_of.py new file mode 100644 index 00000000000..50b046510df --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/cat_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class CatAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'declawed': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'declawed': 'declawed', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """CatAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + declawed (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/category.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/category.py new file mode 100644 index 00000000000..ed167471d35 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/category.py @@ -0,0 +1,173 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Category(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + 'id': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + 'id': 'id', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Category - a model defined in OpenAPI + + Args: + + Keyword Args: + name (str): defaults to "default-name" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): [optional] # noqa: E501 + """ + + name = kwargs.get('name', "default-name") + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child.py new file mode 100644 index 00000000000..d36723dd625 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child.py @@ -0,0 +1,215 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_all_of import ChildAllOf + from petstore_api.model.parent import Parent + globals()['ChildAllOf'] = ChildAllOf + globals()['Parent'] = Parent + + +class Child(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'radio_waves': (bool,), # noqa: E501 + 'tele_vision': (bool,), # noqa: E501 + 'inter_net': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + 'tele_vision': 'teleVision', # noqa: E501 + 'inter_net': 'interNet', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Child - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + radio_waves (bool): [optional] # noqa: E501 + tele_vision (bool): [optional] # noqa: E501 + inter_net (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + ChildAllOf, + Parent, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_all_of.py new file mode 100644 index 00000000000..2339e520bd6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ChildAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'inter_net': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'inter_net': 'interNet', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + inter_net (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat.py new file mode 100644 index 00000000000..70438f3441f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat.py @@ -0,0 +1,215 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_cat_all_of import ChildCatAllOf + from petstore_api.model.parent_pet import ParentPet + globals()['ChildCatAllOf'] = ChildCatAllOf + globals()['ParentPet'] = ParentPet + + +class ChildCat(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'pet_type': (str,), # noqa: E501 + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + } + if not val: + return None + return {'pet_type': val} + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'name': 'name', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildCat - a model defined in OpenAPI + + Keyword Args: + pet_type (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + ChildCatAllOf, + ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat_all_of.py new file mode 100644 index 00000000000..f0f1a1ae6bd --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_cat_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ChildCatAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildCatAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog.py new file mode 100644 index 00000000000..df4956266ae --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog.py @@ -0,0 +1,215 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_dog_all_of import ChildDogAllOf + from petstore_api.model.parent_pet import ParentPet + globals()['ChildDogAllOf'] = ChildDogAllOf + globals()['ParentPet'] = ParentPet + + +class ChildDog(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'pet_type': (str,), # noqa: E501 + 'bark': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + } + if not val: + return None + return {'pet_type': val} + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'bark': 'bark', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildDog - a model defined in OpenAPI + + Keyword Args: + pet_type (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + bark (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + ChildDogAllOf, + ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog_all_of.py new file mode 100644 index 00000000000..d460b68b3d3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_dog_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ChildDogAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'bark': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'bark': 'bark', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildDogAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + bark (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard.py new file mode 100644 index 00000000000..1f50ba403ed --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard.py @@ -0,0 +1,215 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_lizard_all_of import ChildLizardAllOf + from petstore_api.model.parent_pet import ParentPet + globals()['ChildLizardAllOf'] = ChildLizardAllOf + globals()['ParentPet'] = ParentPet + + +class ChildLizard(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'pet_type': (str,), # noqa: E501 + 'loves_rocks': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + } + if not val: + return None + return {'pet_type': val} + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'loves_rocks': 'lovesRocks', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildLizard - a model defined in OpenAPI + + Keyword Args: + pet_type (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + loves_rocks (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + ChildLizardAllOf, + ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard_all_of.py new file mode 100644 index 00000000000..669b9338d79 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/child_lizard_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ChildLizardAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'loves_rocks': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'loves_rocks': 'lovesRocks', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ChildLizardAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + loves_rocks (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/class_model.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/class_model.py new file mode 100644 index 00000000000..18c16f89f90 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/class_model.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ClassModel(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + '_class': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + '_class': '_class', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ClassModel - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _class (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/client.py new file mode 100644 index 00000000000..da615c54773 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/client.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Client(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'client': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'client': 'client', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Client - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + client (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog.py new file mode 100644 index 00000000000..e29ffa33602 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog.py @@ -0,0 +1,218 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.animal import Animal + from petstore_api.model.dog_all_of import DogAllOf + globals()['Animal'] = Animal + globals()['DogAllOf'] = DogAllOf + + +class Dog(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'class_name': (str,), # noqa: E501 + 'breed': (str,), # noqa: E501 + 'color': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + } + if not val: + return None + return {'class_name': val} + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'breed': 'breed', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Dog - a model defined in OpenAPI + + Keyword Args: + class_name (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + breed (str): [optional] # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + Animal, + DogAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog_all_of.py new file mode 100644 index 00000000000..b7b2e7db66d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/dog_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class DogAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'breed': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'breed': 'breed', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """DogAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + breed (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_arrays.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_arrays.py new file mode 100644 index 00000000000..43ebac57de3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_arrays.py @@ -0,0 +1,177 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class EnumArrays(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('just_symbol',): { + '>=': ">=", + '$': "$", + }, + ('array_enum',): { + 'FISH': "fish", + 'CRAB': "crab", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'just_symbol': (str,), # noqa: E501 + 'array_enum': ([str],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'just_symbol': 'just_symbol', # noqa: E501 + 'array_enum': 'array_enum', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """EnumArrays - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + just_symbol (str): [optional] # noqa: E501 + array_enum ([str]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_class.py new file mode 100644 index 00000000000..14188ca31d2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_class.py @@ -0,0 +1,180 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class EnumClass(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('value',): { + '_ABC': "_abc", + '-EFG': "-efg", + '(XYZ)': "(xyz)", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'value': (str,), + } + + @cached_property + def discriminator(): + return None + + + attribute_map = {} + + _composed_schemas = None + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): + """EnumClass - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + + Keyword Args: + value (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = "-efg" + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_test.py new file mode 100644 index 00000000000..79ba0f6a747 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/enum_test.py @@ -0,0 +1,204 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.string_enum import StringEnum + globals()['StringEnum'] = StringEnum + + +class EnumTest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('enum_string_required',): { + 'UPPER': "UPPER", + 'LOWER': "lower", + 'EMPTY': "", + }, + ('enum_string',): { + 'UPPER': "UPPER", + 'LOWER': "lower", + 'EMPTY': "", + }, + ('enum_integer',): { + '1': 1, + '-1': -1, + }, + ('enum_number',): { + '1.1': 1.1, + '-1.2': -1.2, + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'enum_string_required': (str,), # noqa: E501 + 'enum_string': (str,), # noqa: E501 + 'enum_integer': (int,), # noqa: E501 + 'enum_number': (float,), # noqa: E501 + 'string_enum': (StringEnum,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'enum_string_required': 'enum_string_required', # noqa: E501 + 'enum_string': 'enum_string', # noqa: E501 + 'enum_integer': 'enum_integer', # noqa: E501 + 'enum_number': 'enum_number', # noqa: E501 + 'string_enum': 'stringEnum', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, enum_string_required, *args, **kwargs): # noqa: E501 + """EnumTest - a model defined in OpenAPI + + Args: + enum_string_required (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + enum_string (str): [optional] # noqa: E501 + enum_integer (int): [optional] # noqa: E501 + enum_number (float): [optional] # noqa: E501 + string_enum (StringEnum): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.enum_string_required = enum_string_required + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file.py new file mode 100644 index 00000000000..a38cccacc6a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class File(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'source_uri': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'source_uri': 'sourceURI', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """File - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + source_uri (str): Test capitalization. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file_schema_test_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file_schema_test_class.py new file mode 100644 index 00000000000..b8c519ed9c7 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/file_schema_test_class.py @@ -0,0 +1,174 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.file import File + globals()['File'] = File + + +class FileSchemaTestClass(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'file': (File,), # noqa: E501 + 'files': ([File],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'file': 'file', # noqa: E501 + 'files': 'files', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """FileSchemaTestClass - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + file (File): [optional] # noqa: E501 + files ([File]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/format_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/format_test.py new file mode 100644 index 00000000000..494ce2646da --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/format_test.py @@ -0,0 +1,243 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class FormatTest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + ('number',): { + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + }, + ('byte',): { + 'regex': { + 'pattern': r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', # noqa: E501 + }, + }, + ('password',): { + 'max_length': 64, + 'min_length': 10, + }, + ('integer',): { + 'inclusive_maximum': 100, + 'inclusive_minimum': 10, + }, + ('int32',): { + 'inclusive_maximum': 200, + 'inclusive_minimum': 20, + }, + ('float',): { + 'inclusive_maximum': 987.6, + 'inclusive_minimum': 54.3, + }, + ('double',): { + 'inclusive_maximum': 123.4, + 'inclusive_minimum': 67.8, + }, + ('string',): { + 'regex': { + 'pattern': r'^[a-z]+$', # noqa: E501 + 'flags': (re.IGNORECASE) + }, + }, + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'number': (float,), # noqa: E501 + 'byte': (str,), # noqa: E501 + 'date': (date,), # noqa: E501 + 'password': (str,), # noqa: E501 + 'integer': (int,), # noqa: E501 + 'int32': (int,), # noqa: E501 + 'int64': (int,), # noqa: E501 + 'float': (float,), # noqa: E501 + 'double': (float,), # noqa: E501 + 'string': (str,), # noqa: E501 + 'binary': (file_type,), # noqa: E501 + 'date_time': (datetime,), # noqa: E501 + 'uuid': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'number': 'number', # noqa: E501 + 'byte': 'byte', # noqa: E501 + 'date': 'date', # noqa: E501 + 'password': 'password', # noqa: E501 + 'integer': 'integer', # noqa: E501 + 'int32': 'int32', # noqa: E501 + 'int64': 'int64', # noqa: E501 + 'float': 'float', # noqa: E501 + 'double': 'double', # noqa: E501 + 'string': 'string', # noqa: E501 + 'binary': 'binary', # noqa: E501 + 'date_time': 'dateTime', # noqa: E501 + 'uuid': 'uuid', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, number, byte, date, password, *args, **kwargs): # noqa: E501 + """FormatTest - a model defined in OpenAPI + + Args: + number (float): + byte (str): + date (date): + password (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + integer (int): [optional] # noqa: E501 + int32 (int): [optional] # noqa: E501 + int64 (int): [optional] # noqa: E501 + float (float): [optional] # noqa: E501 + double (float): [optional] # noqa: E501 + string (str): [optional] # noqa: E501 + binary (file_type): [optional] # noqa: E501 + date_time (datetime): [optional] # noqa: E501 + uuid (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.number = number + self.byte = byte + self.date = date + self.password = password + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent.py new file mode 100644 index 00000000000..a52744cc3e2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Grandparent(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'radio_waves': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Grandparent - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + radio_waves (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent_animal.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent_animal.py new file mode 100644 index 00000000000..48d3f6d9f0b --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/grandparent_animal.py @@ -0,0 +1,188 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_cat import ChildCat + from petstore_api.model.child_dog import ChildDog + from petstore_api.model.child_lizard import ChildLizard + from petstore_api.model.parent_pet import ParentPet + globals()['ChildCat'] = ChildCat + globals()['ChildDog'] = ChildDog + globals()['ChildLizard'] = ChildLizard + globals()['ParentPet'] = ParentPet + + +class GrandparentAnimal(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'pet_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + lazy_import() + val = { + 'ChildCat': ChildCat, + 'ChildDog': ChildDog, + 'ChildLizard': ChildLizard, + 'ParentPet': ParentPet, + } + if not val: + return None + return {'pet_type': val} + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + """GrandparentAnimal - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.pet_type = pet_type + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/has_only_read_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/has_only_read_only.py new file mode 100644 index 00000000000..c94781ae2c4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/has_only_read_only.py @@ -0,0 +1,169 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class HasOnlyReadOnly(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'bar': (str,), # noqa: E501 + 'foo': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'bar': 'bar', # noqa: E501 + 'foo': 'foo', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """HasOnlyReadOnly - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + bar (str): [optional] # noqa: E501 + foo (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/list.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/list.py new file mode 100644 index 00000000000..09c762d6a79 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/list.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class List(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + '_123_list': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + '_123_list': '123-list', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """List - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _123_list (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/map_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/map_test.py new file mode 100644 index 00000000000..169fb9d88ee --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/map_test.py @@ -0,0 +1,184 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.string_boolean_map import StringBooleanMap + globals()['StringBooleanMap'] = StringBooleanMap + + +class MapTest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('map_of_enum_string',): { + 'UPPER': "UPPER", + 'LOWER': "lower", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'map_map_of_string': ({str: ({str: (str,)},)},), # noqa: E501 + 'map_of_enum_string': ({str: (str,)},), # noqa: E501 + 'direct_map': ({str: (bool,)},), # noqa: E501 + 'indirect_map': (StringBooleanMap,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'map_map_of_string': 'map_map_of_string', # noqa: E501 + 'map_of_enum_string': 'map_of_enum_string', # noqa: E501 + 'direct_map': 'direct_map', # noqa: E501 + 'indirect_map': 'indirect_map', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """MapTest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + map_map_of_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 + map_of_enum_string ({str: (str,)}): [optional] # noqa: E501 + direct_map ({str: (bool,)}): [optional] # noqa: E501 + indirect_map (StringBooleanMap): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/mixed_properties_and_additional_properties_class.py new file mode 100644 index 00000000000..01df80d9d62 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/mixed_properties_and_additional_properties_class.py @@ -0,0 +1,177 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.animal import Animal + globals()['Animal'] = Animal + + +class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'uuid': (str,), # noqa: E501 + 'date_time': (datetime,), # noqa: E501 + 'map': ({str: (Animal,)},), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'uuid': 'uuid', # noqa: E501 + 'date_time': 'dateTime', # noqa: E501 + 'map': 'map', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + uuid (str): [optional] # noqa: E501 + date_time (datetime): [optional] # noqa: E501 + map ({str: (Animal,)}): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model200_response.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model200_response.py new file mode 100644 index 00000000000..46b155b6523 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model200_response.py @@ -0,0 +1,169 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Model200Response(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (int,), # noqa: E501 + '_class': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + '_class': 'class', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Model200Response - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (int): [optional] # noqa: E501 + _class (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model_return.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model_return.py new file mode 100644 index 00000000000..377b3507a8b --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/model_return.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ModelReturn(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + '_return': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + '_return': 'return', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ModelReturn - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _return (int): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/name.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/name.py new file mode 100644 index 00000000000..1432e185ad6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/name.py @@ -0,0 +1,178 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Name(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (int,), # noqa: E501 + 'snake_case': (int,), # noqa: E501 + '_property': (str,), # noqa: E501 + '_123_number': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + 'snake_case': 'snake_case', # noqa: E501 + '_property': 'property', # noqa: E501 + '_123_number': '123Number', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, name, *args, **kwargs): # noqa: E501 + """Name - a model defined in OpenAPI + + Args: + name (int): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + snake_case (int): [optional] # noqa: E501 + _property (str): [optional] # noqa: E501 + _123_number (int): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_only.py new file mode 100644 index 00000000000..d4892dbede5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_only.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class NumberOnly(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'just_number': (float,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'just_number': 'JustNumber', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """NumberOnly - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + just_number (float): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_with_validations.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_with_validations.py new file mode 100644 index 00000000000..458a7945975 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/number_with_validations.py @@ -0,0 +1,183 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class NumberWithValidations(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + ('value',): { + 'inclusive_maximum': 2E+1, + 'inclusive_minimum': 1E+1, + }, + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'value': (float,), + } + + @cached_property + def discriminator(): + return None + + + attribute_map = {} + + _composed_schemas = None + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): + """NumberWithValidations - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (float): # noqa: E501 + + Keyword Args: + value (float): # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/object_model_with_ref_props.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/object_model_with_ref_props.py new file mode 100644 index 00000000000..b1dc4bf82e2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/object_model_with_ref_props.py @@ -0,0 +1,177 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.number_with_validations import NumberWithValidations + globals()['NumberWithValidations'] = NumberWithValidations + + +class ObjectModelWithRefProps(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'my_number': (NumberWithValidations,), # noqa: E501 + 'my_string': (str,), # noqa: E501 + 'my_boolean': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'my_number': 'my_number', # noqa: E501 + 'my_string': 'my_string', # noqa: E501 + 'my_boolean': 'my_boolean', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ObjectModelWithRefProps - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + my_number (NumberWithValidations): [optional] # noqa: E501 + my_string (str): [optional] # noqa: E501 + my_boolean (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/order.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/order.py new file mode 100644 index 00000000000..b42f066848a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/order.py @@ -0,0 +1,186 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Order(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('status',): { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'id': (int,), # noqa: E501 + 'pet_id': (int,), # noqa: E501 + 'quantity': (int,), # noqa: E501 + 'ship_date': (datetime,), # noqa: E501 + 'status': (str,), # noqa: E501 + 'complete': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + 'pet_id': 'petId', # noqa: E501 + 'quantity': 'quantity', # noqa: E501 + 'ship_date': 'shipDate', # noqa: E501 + 'status': 'status', # noqa: E501 + 'complete': 'complete', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Order - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): [optional] # noqa: E501 + pet_id (int): [optional] # noqa: E501 + quantity (int): [optional] # noqa: E501 + ship_date (datetime): [optional] # noqa: E501 + status (str): Order Status. [optional] # noqa: E501 + complete (bool): [optional] if omitted the server will use the default value of False # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent.py new file mode 100644 index 00000000000..b07448d9e1f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent.py @@ -0,0 +1,212 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.grandparent import Grandparent + from petstore_api.model.parent_all_of import ParentAllOf + globals()['Grandparent'] = Grandparent + globals()['ParentAllOf'] = ParentAllOf + + +class Parent(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'radio_waves': (bool,), # noqa: E501 + 'tele_vision': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + 'tele_vision': 'teleVision', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Parent - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + radio_waves (bool): [optional] # noqa: E501 + tele_vision (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + Grandparent, + ParentAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_all_of.py new file mode 100644 index 00000000000..0d109f25a4c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_all_of.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ParentAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'tele_vision': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'tele_vision': 'teleVision', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ParentAllOf - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tele_vision (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_pet.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_pet.py new file mode 100644 index 00000000000..597e30bb9c4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/parent_pet.py @@ -0,0 +1,219 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.child_cat import ChildCat + from petstore_api.model.child_dog import ChildDog + from petstore_api.model.child_lizard import ChildLizard + from petstore_api.model.grandparent_animal import GrandparentAnimal + globals()['ChildCat'] = ChildCat + globals()['ChildDog'] = ChildDog + globals()['ChildLizard'] = ChildLizard + globals()['GrandparentAnimal'] = GrandparentAnimal + + +class ParentPet(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'pet_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + lazy_import() + val = { + 'ChildCat': ChildCat, + 'ChildDog': ChildDog, + 'ChildLizard': ChildLizard, + } + if not val: + return None + return {'pet_type': val} + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ParentPet - a model defined in OpenAPI + + Keyword Args: + pet_type (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + GrandparentAnimal, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/pet.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/pet.py new file mode 100644 index 00000000000..e9f1e30a319 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/pet.py @@ -0,0 +1,197 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.category import Category + from petstore_api.model.tag import Tag + globals()['Category'] = Category + globals()['Tag'] = Tag + + +class Pet(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('status',): { + 'AVAILABLE': "available", + 'PENDING': "pending", + 'SOLD': "sold", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'name': (str,), # noqa: E501 + 'photo_urls': ([str],), # noqa: E501 + 'id': (int,), # noqa: E501 + 'category': (Category,), # noqa: E501 + 'tags': ([Tag],), # noqa: E501 + 'status': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + 'photo_urls': 'photoUrls', # noqa: E501 + 'id': 'id', # noqa: E501 + 'category': 'category', # noqa: E501 + 'tags': 'tags', # noqa: E501 + 'status': 'status', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, name, photo_urls, *args, **kwargs): # noqa: E501 + """Pet - a model defined in OpenAPI + + Args: + name (str): + photo_urls ([str]): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): [optional] # noqa: E501 + category (Category): [optional] # noqa: E501 + tags ([Tag]): [optional] # noqa: E501 + status (str): pet status in the store. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.photo_urls = photo_urls + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/player.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/player.py new file mode 100644 index 00000000000..6e4485fb650 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/player.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Player(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + 'enemy_player': (Player,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + 'enemy_player': 'enemyPlayer', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, name, *args, **kwargs): # noqa: E501 + """Player - a model defined in OpenAPI + + Args: + name (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + enemy_player (Player): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/read_only_first.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/read_only_first.py new file mode 100644 index 00000000000..5c68eab91ea --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/read_only_first.py @@ -0,0 +1,169 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class ReadOnlyFirst(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'bar': (str,), # noqa: E501 + 'baz': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'bar': 'bar', # noqa: E501 + 'baz': 'baz', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ReadOnlyFirst - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + bar (str): [optional] # noqa: E501 + baz (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/special_model_name.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/special_model_name.py new file mode 100644 index 00000000000..823e7759663 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/special_model_name.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class SpecialModelName(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'special_property_name': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'special_property_name': '$special[property.name]', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """SpecialModelName - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + special_property_name (int): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_boolean_map.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_boolean_map.py new file mode 100644 index 00000000000..4ac52699183 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_boolean_map.py @@ -0,0 +1,169 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class StringBooleanMap(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """StringBooleanMap - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_enum.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_enum.py new file mode 100644 index 00000000000..37dc04332ca --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/string_enum.py @@ -0,0 +1,184 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class StringEnum(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('value',): { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered", + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'value': (str,), + } + + @cached_property + def discriminator(): + return None + + + attribute_map = {} + + _composed_schemas = None + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): + """StringEnum - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 + + Keyword Args: + value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/tag.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/tag.py new file mode 100644 index 00000000000..d3dcb78b7ea --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/tag.py @@ -0,0 +1,172 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class Tag(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'id': (int,), # noqa: E501 + 'name': (str,), # noqa: E501 + 'full_name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + 'name': 'name', # noqa: E501 + 'full_name': 'fullName', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Tag - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): [optional] # noqa: E501 + name (str): [optional] # noqa: E501 + full_name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_default.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_default.py new file mode 100644 index 00000000000..324b131f3a2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_default.py @@ -0,0 +1,195 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class TypeHolderDefault(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'string_item': (str,), # noqa: E501 + 'number_item': (float,), # noqa: E501 + 'integer_item': (int,), # noqa: E501 + 'bool_item': (bool,), # noqa: E501 + 'array_item': ([int],), # noqa: E501 + 'date_item': (date,), # noqa: E501 + 'datetime_item': (datetime,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'string_item': 'string_item', # noqa: E501 + 'number_item': 'number_item', # noqa: E501 + 'integer_item': 'integer_item', # noqa: E501 + 'bool_item': 'bool_item', # noqa: E501 + 'array_item': 'array_item', # noqa: E501 + 'date_item': 'date_item', # noqa: E501 + 'datetime_item': 'datetime_item', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, array_item, *args, **kwargs): # noqa: E501 + """TypeHolderDefault - a model defined in OpenAPI + + Args: + array_item ([int]): + + Keyword Args: + string_item (str): defaults to "what" # noqa: E501 + number_item (float): defaults to 1.234 # noqa: E501 + integer_item (int): defaults to -2 # noqa: E501 + bool_item (bool): defaults to True # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + date_item (date): [optional] # noqa: E501 + datetime_item (datetime): [optional] # noqa: E501 + """ + + string_item = kwargs.get('string_item', "what") + number_item = kwargs.get('number_item', 1.234) + integer_item = kwargs.get('integer_item', -2) + bool_item = kwargs.get('bool_item', True) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.string_item = string_item + self.number_item = number_item + self.integer_item = integer_item + self.bool_item = bool_item + self.array_item = array_item + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_example.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_example.py new file mode 100644 index 00000000000..30bbba178f4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/type_holder_example.py @@ -0,0 +1,197 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class TypeHolderExample(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('string_item',): { + 'WHAT': "what", + }, + ('number_item',): { + '1.234': 1.234, + }, + ('integer_item',): { + '-2': -2, + }, + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'string_item': (str,), # noqa: E501 + 'number_item': (float,), # noqa: E501 + 'integer_item': (int,), # noqa: E501 + 'bool_item': (bool,), # noqa: E501 + 'array_item': ([int],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'string_item': 'string_item', # noqa: E501 + 'number_item': 'number_item', # noqa: E501 + 'integer_item': 'integer_item', # noqa: E501 + 'bool_item': 'bool_item', # noqa: E501 + 'array_item': 'array_item', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, bool_item, array_item, *args, **kwargs): # noqa: E501 + """TypeHolderExample - a model defined in OpenAPI + + Args: + bool_item (bool): + array_item ([int]): + + Keyword Args: + string_item (str): defaults to "what", must be one of ["what", ] # noqa: E501 + number_item (float): defaults to 1.234, must be one of [1.234, ] # noqa: E501 + integer_item (int): defaults to -2, must be one of [-2, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + string_item = kwargs.get('string_item', "what") + number_item = kwargs.get('number_item', 1.234) + integer_item = kwargs.get('integer_item', -2) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.string_item = string_item + self.number_item = number_item + self.integer_item = integer_item + self.bool_item = bool_item + self.array_item = array_item + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/user.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/user.py new file mode 100644 index 00000000000..9a3cd081411 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/user.py @@ -0,0 +1,187 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class User(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'id': (int,), # noqa: E501 + 'username': (str,), # noqa: E501 + 'first_name': (str,), # noqa: E501 + 'last_name': (str,), # noqa: E501 + 'email': (str,), # noqa: E501 + 'password': (str,), # noqa: E501 + 'phone': (str,), # noqa: E501 + 'user_status': (int,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + 'username': 'username', # noqa: E501 + 'first_name': 'firstName', # noqa: E501 + 'last_name': 'lastName', # noqa: E501 + 'email': 'email', # noqa: E501 + 'password': 'password', # noqa: E501 + 'phone': 'phone', # noqa: E501 + 'user_status': 'userStatus', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """User - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): [optional] # noqa: E501 + username (str): [optional] # noqa: E501 + first_name (str): [optional] # noqa: E501 + last_name (str): [optional] # noqa: E501 + email (str): [optional] # noqa: E501 + password (str): [optional] # noqa: E501 + phone (str): [optional] # noqa: E501 + user_status (int): User Status. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/xml_item.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/xml_item.py new file mode 100644 index 00000000000..8401b3f4007 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/xml_item.py @@ -0,0 +1,250 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class XmlItem(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'attribute_string': (str,), # noqa: E501 + 'attribute_number': (float,), # noqa: E501 + 'attribute_integer': (int,), # noqa: E501 + 'attribute_boolean': (bool,), # noqa: E501 + 'wrapped_array': ([int],), # noqa: E501 + 'name_string': (str,), # noqa: E501 + 'name_number': (float,), # noqa: E501 + 'name_integer': (int,), # noqa: E501 + 'name_boolean': (bool,), # noqa: E501 + 'name_array': ([int],), # noqa: E501 + 'name_wrapped_array': ([int],), # noqa: E501 + 'prefix_string': (str,), # noqa: E501 + 'prefix_number': (float,), # noqa: E501 + 'prefix_integer': (int,), # noqa: E501 + 'prefix_boolean': (bool,), # noqa: E501 + 'prefix_array': ([int],), # noqa: E501 + 'prefix_wrapped_array': ([int],), # noqa: E501 + 'namespace_string': (str,), # noqa: E501 + 'namespace_number': (float,), # noqa: E501 + 'namespace_integer': (int,), # noqa: E501 + 'namespace_boolean': (bool,), # noqa: E501 + 'namespace_array': ([int],), # noqa: E501 + 'namespace_wrapped_array': ([int],), # noqa: E501 + 'prefix_ns_string': (str,), # noqa: E501 + 'prefix_ns_number': (float,), # noqa: E501 + 'prefix_ns_integer': (int,), # noqa: E501 + 'prefix_ns_boolean': (bool,), # noqa: E501 + 'prefix_ns_array': ([int],), # noqa: E501 + 'prefix_ns_wrapped_array': ([int],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'attribute_string': 'attribute_string', # noqa: E501 + 'attribute_number': 'attribute_number', # noqa: E501 + 'attribute_integer': 'attribute_integer', # noqa: E501 + 'attribute_boolean': 'attribute_boolean', # noqa: E501 + 'wrapped_array': 'wrapped_array', # noqa: E501 + 'name_string': 'name_string', # noqa: E501 + 'name_number': 'name_number', # noqa: E501 + 'name_integer': 'name_integer', # noqa: E501 + 'name_boolean': 'name_boolean', # noqa: E501 + 'name_array': 'name_array', # noqa: E501 + 'name_wrapped_array': 'name_wrapped_array', # noqa: E501 + 'prefix_string': 'prefix_string', # noqa: E501 + 'prefix_number': 'prefix_number', # noqa: E501 + 'prefix_integer': 'prefix_integer', # noqa: E501 + 'prefix_boolean': 'prefix_boolean', # noqa: E501 + 'prefix_array': 'prefix_array', # noqa: E501 + 'prefix_wrapped_array': 'prefix_wrapped_array', # noqa: E501 + 'namespace_string': 'namespace_string', # noqa: E501 + 'namespace_number': 'namespace_number', # noqa: E501 + 'namespace_integer': 'namespace_integer', # noqa: E501 + 'namespace_boolean': 'namespace_boolean', # noqa: E501 + 'namespace_array': 'namespace_array', # noqa: E501 + 'namespace_wrapped_array': 'namespace_wrapped_array', # noqa: E501 + 'prefix_ns_string': 'prefix_ns_string', # noqa: E501 + 'prefix_ns_number': 'prefix_ns_number', # noqa: E501 + 'prefix_ns_integer': 'prefix_ns_integer', # noqa: E501 + 'prefix_ns_boolean': 'prefix_ns_boolean', # noqa: E501 + 'prefix_ns_array': 'prefix_ns_array', # noqa: E501 + 'prefix_ns_wrapped_array': 'prefix_ns_wrapped_array', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """XmlItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attribute_string (str): [optional] # noqa: E501 + attribute_number (float): [optional] # noqa: E501 + attribute_integer (int): [optional] # noqa: E501 + attribute_boolean (bool): [optional] # noqa: E501 + wrapped_array ([int]): [optional] # noqa: E501 + name_string (str): [optional] # noqa: E501 + name_number (float): [optional] # noqa: E501 + name_integer (int): [optional] # noqa: E501 + name_boolean (bool): [optional] # noqa: E501 + name_array ([int]): [optional] # noqa: E501 + name_wrapped_array ([int]): [optional] # noqa: E501 + prefix_string (str): [optional] # noqa: E501 + prefix_number (float): [optional] # noqa: E501 + prefix_integer (int): [optional] # noqa: E501 + prefix_boolean (bool): [optional] # noqa: E501 + prefix_array ([int]): [optional] # noqa: E501 + prefix_wrapped_array ([int]): [optional] # noqa: E501 + namespace_string (str): [optional] # noqa: E501 + namespace_number (float): [optional] # noqa: E501 + namespace_integer (int): [optional] # noqa: E501 + namespace_boolean (bool): [optional] # noqa: E501 + namespace_array ([int]): [optional] # noqa: E501 + namespace_wrapped_array ([int]): [optional] # noqa: E501 + prefix_ns_string (str): [optional] # noqa: E501 + prefix_ns_number (float): [optional] # noqa: E501 + prefix_ns_integer (int): [optional] # noqa: E501 + prefix_ns_boolean (bool): [optional] # noqa: E501 + prefix_ns_array ([int]): [optional] # noqa: E501 + prefix_ns_wrapped_array ([int]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py new file mode 100644 index 00000000000..b6d5934170a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py @@ -0,0 +1,1848 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from datetime import date, datetime # noqa: F401 +import inspect +import io +import os +import pprint +import re +import tempfile + +from dateutil.parser import parse + +from petstore_api.exceptions import ( + ApiKeyError, + ApiAttributeError, + ApiTypeError, + ApiValueError, +) + +none_type = type(None) +file_type = io.IOBase + + +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on fuction methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + if self.result_key in vars(self): + return vars(self)[self.result_key] + else: + result = self._fn() + setattr(self, self.result_key, result) + return result + + +PRIMITIVE_TYPES = (list, float, int, bool, datetime, date, str, file_type) + +def allows_single_value_input(cls): + """ + This function returns True if the input composed schema model or any + descendant model allows a value only input + This is true for cases where oneOf contains items like: + oneOf: + - float + - NumberWithValidation + - StringEnum + - ArrayModel + - null + TODO: lru_cache this + """ + if ( + issubclass(cls, ModelSimple) or + cls in PRIMITIVE_TYPES + ): + return True + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return False + return any(allows_single_value_input(c) for c in cls._composed_schemas['oneOf']) + return False + +def composed_model_input_classes(cls): + """ + This function returns a list of the possible models that can be accepted as + inputs. + TODO: lru_cache this + """ + if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES: + return [cls] + elif issubclass(cls, ModelNormal): + if cls.discriminator is None: + return [cls] + else: + return get_discriminated_classes(cls) + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return [] + if cls.discriminator is None: + input_classes = [] + for c in cls._composed_schemas['oneOf']: + input_classes.extend(composed_model_input_classes(c)) + return input_classes + else: + return get_discriminated_classes(cls) + return [] + + +class OpenApiModel(object): + """The base class for all OpenAPIModels""" + + def set_attribute(self, name, value): + # this is only used to set properties on self + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._spec_property_naming, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value, + self._configuration + ) + self.__dict__['_data_store'][name] = value + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other + + def __setattr__(self, attr, value): + """set the value of an attribute using dot notation: `instance.attr = val`""" + self[attr] = value + + def __getattr__(self, attr): + """get the value of an attribute using dot notation: `instance.attr`""" + return self.__getitem__(attr) + + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: If Animal has a discriminator + # petType and we pass in "Dog", and the class Dog + # allOf includes Animal, we move through Animal + # once using the discriminator, and pick Dog. + # Then in the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return super(OpenApiModel, cls).__new__(cls) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get('_path_to_item', ()) + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return super(OpenApiModel, cls).__new__(cls) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + + +class ModelSimple(OpenApiModel): + """the parent class of models whose type != object in their + swagger/openapi""" + + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" + if name in self.required_properties: + return self.__dict__[name] + + return self.__dict__['_data_store'].get(name, default) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + if name in self: + return self.get(name) + + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + + def __contains__(self, name): + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" + if name in self.required_properties: + return name in self.__dict__ + + return name in self.__dict__['_data_store'] + + def to_str(self): + """Returns the string representation of the model""" + return str(self.value) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + return vals_equal + + +class ModelNormal(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi""" + + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" + if name in self.required_properties: + return self.__dict__[name] + + return self.__dict__['_data_store'].get(name, default) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + if name in self: + return self.get(name) + + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + + def __contains__(self, name): + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" + if name in self.required_properties: + return name in self.__dict__ + + return name in self.__dict__['_data_store'] + + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in self._data_store.items(): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not vals_equal: + return False + return True + + +class ModelComposed(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi and have oneOf/allOf/anyOf + + When one sets a property we use var_name_to_model_instances to store the value in + the correct class instances + run any type checking + validation code. + When one gets a property we use var_name_to_model_instances to get the value + from the correct class instances. + This allows multiple composed schemas to contain the same property with additive + constraints on the value. + + _composed_schemas (dict) stores the anyOf/allOf/oneOf classes + key (str): allOf/oneOf/anyOf + value (list): the classes in the XOf definition. + Note: none_type can be included when the openapi document version >= 3.1.0 + _composed_instances (list): stores a list of instances of the composed schemas + defined in _composed_schemas. When properties are accessed in the self instance, + they are returned from the self._data_store or the data stores in the instances + in self._composed_schemas + _var_name_to_model_instances (dict): maps between a variable name on self and + the composed instances (self included) which contain that data + key (str): property name + value (list): list of class instances, self or instances in _composed_instances + which contain the value that the key is referring to. + """ + + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" + if name in self.required_properties: + self.__dict__[name] = value + return + + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas + + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None + + __unset_attribute_value__ = object() + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" + if name in self.required_properties: + return self.__dict__[name] + + # get the attribute from the correct instance + model_instances = self._var_name_to_model_instances.get(name) + values = [] + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same + if model_instances: + for model_instance in model_instances: + if name in model_instance._data_store: + v = model_instance._data_store[name] + if v not in values: + values.append(v) + len_values = len(values) + if len_values == 0: + return default + elif len_values == 1: + return values[0] + elif len_values > 1: + raise ApiValueError( + "Values stored for property {0} in {1} differ when looking " + "at self and self's composed instances. All values must be " + "the same".format(name, type(self).__name__), + [e for e in [self._path_to_item, name] if e] + ) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + value = self.get(name, self.__unset_attribute_value__) + if value is self.__unset_attribute_value__: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + return value + + def __contains__(self, name): + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" + + if name in self.required_properties: + return name in self.__dict__ + + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + + if model_instances: + for model_instance in model_instances: + if name in model_instance._data_store: + return True + + return False + + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in self._data_store.items(): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not vals_equal: + return False + return True + + +COERCION_INDEX_BY_TYPE = { + ModelComposed: 0, + ModelNormal: 1, + ModelSimple: 2, + none_type: 3, # The type of 'None'. + list: 4, + dict: 5, + float: 6, + int: 7, + bool: 8, + datetime: 9, + date: 10, + str: 11, + file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type. +} + +# these are used to limit what type conversions we try to do +# when we have a valid type already and we want to try converting +# to another type +UPCONVERSION_TYPE_PAIRS = ( + (str, datetime), + (str, date), + (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. + (list, ModelComposed), + (dict, ModelComposed), + (str, ModelComposed), + (int, ModelComposed), + (float, ModelComposed), + (list, ModelComposed), + (list, ModelNormal), + (dict, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), +) + +COERCIBLE_TYPE_PAIRS = { + False: ( # client instantiation of a model with client data + # (dict, ModelComposed), + # (list, ModelComposed), + # (dict, ModelNormal), + # (list, ModelNormal), + # (str, ModelSimple), + # (int, ModelSimple), + # (float, ModelSimple), + # (list, ModelSimple), + # (str, int), + # (str, float), + # (str, datetime), + # (str, date), + # (int, str), + # (float, str), + ), + True: ( # server -> client data + (dict, ModelComposed), + (list, ModelComposed), + (dict, ModelNormal), + (list, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), + # (str, int), + # (str, float), + (str, datetime), + (str, date), + # (int, str), + # (float, str), + (str, file_type) + ), +} + + +def get_simple_class(input_value): + """Returns an input_value's simple class that we will use for type checking + Python2: + float and int will return int, where int is the python3 int backport + str and unicode will return str, where str is the python3 str backport + Note: float and int ARE both instances of int backport + Note: str_py2 and unicode_py2 are NOT both instances of str backport + + Args: + input_value (class/class_instance): the item for which we will return + the simple class + """ + if isinstance(input_value, type): + # input_value is a class + return input_value + elif isinstance(input_value, tuple): + return tuple + elif isinstance(input_value, list): + return list + elif isinstance(input_value, dict): + return dict + elif isinstance(input_value, none_type): + return none_type + elif isinstance(input_value, file_type): + return file_type + elif isinstance(input_value, bool): + # this must be higher than the int check because + # isinstance(True, int) == True + return bool + elif isinstance(input_value, int): + return int + elif isinstance(input_value, datetime): + # this must be higher than the date check because + # isinstance(datetime_instance, date) == True + return datetime + elif isinstance(input_value, date): + return date + elif isinstance(input_value, str): + return str + return type(input_value) + + +def check_allowed_values(allowed_values, input_variable_path, input_values): + """Raises an exception if the input_values are not allowed + + Args: + allowed_values (dict): the allowed_values dict + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking to see if they are in allowed_values + """ + these_allowed_values = list(allowed_values[input_variable_path].values()) + if (isinstance(input_values, list) + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), + raise ApiValueError( + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (isinstance(input_values, dict) + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) + raise ApiValueError( + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): + raise ApiValueError( + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) + ) + + +def is_json_validation_enabled(schema_keyword, configuration=None): + """Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + """ + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + +def check_validations( + validations, input_variable_path, input_values, + configuration=None): + """Raises an exception if the input_values are invalid + + Args: + validations (dict): the validation dictionary. + input_variable_path (tuple): the path to the input variable. + input_values (list/str/int/float/date/datetime): the values that we + are checking. + configuration (Configuration): the configuration class. + """ + + if input_values is None: + return + + current_validations = validations[input_variable_path] + if (is_json_validation_enabled('multipleOf', configuration) and + 'multiple_of' in current_validations and + isinstance(input_values, (int, float)) and + not (float(input_values) / current_validations['multiple_of']).is_integer()): + # Note 'multipleOf' will be as good as the floating point arithmetic. + raise ApiValueError( + "Invalid value for `%s`, value must be a multiple of " + "`%s`" % ( + input_variable_path[0], + current_validations['multiple_of'] + ) + ) + + if (is_json_validation_enabled('maxLength', configuration) and + 'max_length' in current_validations and + len(input_values) > current_validations['max_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) + ) + + if (is_json_validation_enabled('minLength', configuration) and + 'min_length' in current_validations and + len(input_values) < current_validations['min_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be greater than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) + ) + + if (is_json_validation_enabled('maxItems', configuration) and + 'max_items' in current_validations and + len(input_values) > current_validations['max_items']): + raise ApiValueError( + "Invalid value for `%s`, number of items must be less than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) + ) + + if (is_json_validation_enabled('minItems', configuration) and + 'min_items' in current_validations and + len(input_values) < current_validations['min_items']): + raise ValueError( + "Invalid value for `%s`, number of items must be greater than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) + ) + + items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum') + if (any(item in current_validations for item in items)): + if isinstance(input_values, list): + max_val = max(input_values) + min_val = min(input_values) + elif isinstance(input_values, dict): + max_val = max(input_values.values()) + min_val = min(input_values.values()) + else: + max_val = input_values + min_val = input_values + + if (is_json_validation_enabled('exclusiveMaximum', configuration) and + 'exclusive_maximum' in current_validations and + max_val >= current_validations['exclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('maximum', configuration) and + 'inclusive_maximum' in current_validations and + max_val > current_validations['inclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('exclusiveMinimum', configuration) and + 'exclusive_minimum' in current_validations and + min_val <= current_validations['exclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('minimum', configuration) and + 'inclusive_minimum' in current_validations and + min_val < current_validations['inclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than or equal " + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) + ) + flags = current_validations.get('regex', {}).get('flags', 0) + if (is_json_validation_enabled('pattern', configuration) and + 'regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): + err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'] + ) + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + err_msg = r"%s with flags=`%s`" % (err_msg, flags) + raise ApiValueError(err_msg) + + +def order_response_types(required_types): + """Returns the required types sorted in coercion order + + Args: + required_types (list/tuple): collection of classes or instance of + list or dict with class information inside it. + + Returns: + (list): coercion order sorted collection of classes or instance + of list or dict with class information inside it. + """ + + def index_getter(class_or_instance): + if isinstance(class_or_instance, list): + return COERCION_INDEX_BY_TYPE[list] + elif isinstance(class_or_instance, dict): + return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): + return COERCION_INDEX_BY_TYPE[ModelComposed] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelNormal)): + return COERCION_INDEX_BY_TYPE[ModelNormal] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelSimple)): + return COERCION_INDEX_BY_TYPE[ModelSimple] + elif class_or_instance in COERCION_INDEX_BY_TYPE: + return COERCION_INDEX_BY_TYPE[class_or_instance] + raise ApiValueError("Unsupported type: %s" % class_or_instance) + + sorted_types = sorted( + required_types, + key=lambda class_or_instance: index_getter(class_or_instance) + ) + return sorted_types + + +def remove_uncoercible(required_types_classes, current_item, spec_property_naming, + must_convert=True): + """Only keeps the type conversions that are possible + + Args: + required_types_classes (tuple): tuple of classes that are required + these should be ordered by COERCION_INDEX_BY_TYPE + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. + current_item (any): the current item (input data) to be converted + + Keyword Args: + must_convert (bool): if True the item to convert is of the wrong + type and we want a big list of coercibles + if False, we want a limited list of coercibles + + Returns: + (list): the remaining coercible required types, classes only + """ + current_type_simple = get_simple_class(current_item) + + results_classes = [] + for required_type_class in required_types_classes: + # convert our models to OpenApiModel + required_type_class_simplified = required_type_class + if isinstance(required_type_class_simplified, type): + if issubclass(required_type_class_simplified, ModelComposed): + required_type_class_simplified = ModelComposed + elif issubclass(required_type_class_simplified, ModelNormal): + required_type_class_simplified = ModelNormal + elif issubclass(required_type_class_simplified, ModelSimple): + required_type_class_simplified = ModelSimple + + if required_type_class_simplified == current_type_simple: + # don't consider converting to one's own class + continue + + class_pair = (current_type_simple, required_type_class_simplified) + if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[spec_property_naming]: + results_classes.append(required_type_class) + elif class_pair in UPCONVERSION_TYPE_PAIRS: + results_classes.append(required_type_class) + return results_classes + +def get_discriminated_classes(cls): + """ + Returns all the classes that a discriminator converts to + TODO: lru_cache this + """ + possible_classes = [] + key = list(cls.discriminator.keys())[0] + if is_type_nullable(cls): + possible_classes.append(cls) + for discr_cls in cls.discriminator[key].values(): + if hasattr(discr_cls, 'discriminator') and discr_cls.discriminator is not None: + possible_classes.extend(get_discriminated_classes(discr_cls)) + else: + possible_classes.append(discr_cls) + return possible_classes + + +def get_possible_classes(cls, from_server_context): + # TODO: lru_cache this + possible_classes = [cls] + if from_server_context: + return possible_classes + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + possible_classes = [] + possible_classes.extend(get_discriminated_classes(cls)) + elif issubclass(cls, ModelComposed): + possible_classes.extend(composed_model_input_classes(cls)) + return possible_classes + + +def get_required_type_classes(required_types_mixed, spec_property_naming): + """Converts the tuple required_types into a tuple and a dict described + below + + Args: + required_types_mixed (tuple/list): will contain either classes or + instance of list or dict + spec_property_naming (bool): if True these values came from the + server, and we use the data types in our endpoints. + If False, we are client side and we need to include + oneOf and discriminator classes inside the data types in our endpoints + + Returns: + (valid_classes, dict_valid_class_to_child_types_mixed): + valid_classes (tuple): the valid classes that the current item + should be + dict_valid_class_to_child_types_mixed (dict): + valid_class (class): this is the key + child_types_mixed (list/dict/tuple): describes the valid child + types + """ + valid_classes = [] + child_req_types_by_current_type = {} + for required_type in required_types_mixed: + if isinstance(required_type, list): + valid_classes.append(list) + child_req_types_by_current_type[list] = required_type + elif isinstance(required_type, tuple): + valid_classes.append(tuple) + child_req_types_by_current_type[tuple] = required_type + elif isinstance(required_type, dict): + valid_classes.append(dict) + child_req_types_by_current_type[dict] = required_type[str] + else: + valid_classes.extend(get_possible_classes(required_type, spec_property_naming)) + return tuple(valid_classes), child_req_types_by_current_type + + +def change_keys_js_to_python(input_dict, model_class): + """ + Converts from javascript_key keys in the input_dict to python_keys in + the output dict using the mapping in model_class. + If the input_dict contains a key which does not declared in the model_class, + the key is added to the output dict as is. The assumption is the model_class + may have undeclared properties (additionalProperties attribute in the OAS + document). + """ + + if getattr(model_class, 'attribute_map', None) is None: + return input_dict + output_dict = {} + reversed_attr_map = {value: key for key, value in + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): + python_key = reversed_attr_map.get(javascript_key) + if python_key is None: + # if the key is unknown, it is in error or it is an + # additionalProperties variable + python_key = javascript_key + output_dict[python_key] = value + return output_dict + + +def get_type_error(var_value, path_to_item, valid_classes, key_type=False): + error_msg = type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type + ) + + +def deserialize_primitive(data, klass, path_to_item): + """Deserializes string to primitive type. + + :param data: str/int/float + :param klass: str/class the class to convert to + + :return: int, float, str, bool, date, datetime + """ + additional_message = "" + try: + if klass in {datetime, date}: + additional_message = ( + "If you need your parameter to have a fallback " + "string value, please set its type as `type: {}` in your " + "spec. That allows the value to be any type. " + ) + if klass == datetime: + if len(data) < 8: + raise ValueError("This is not a datetime") + # The string should be in iso8601 datetime format. + parsed_datetime = parse(data) + date_only = ( + parsed_datetime.hour == 0 and + parsed_datetime.minute == 0 and + parsed_datetime.second == 0 and + parsed_datetime.tzinfo is None and + 8 <= len(data) <= 10 + ) + if date_only: + raise ValueError("This is a date, not a datetime") + return parsed_datetime + elif klass == date: + if len(data) < 8: + raise ValueError("This is not a date") + return parse(data).date() + else: + converted_value = klass(data) + if isinstance(data, str) and klass == float: + if str(converted_value) != data: + # '7' -> 7.0 -> '7.0' != '7' + raise ValueError('This is not a float') + return converted_value + except (OverflowError, ValueError) as ex: + # parse can raise OverflowError + raise ApiValueError( + "{0}Failed to parse {1} as {2}".format( + additional_message, repr(data), klass.__name__ + ), + path_to_item=path_to_item + ) from ex + + +def get_discriminator_class(model_class, + discr_name, + discr_value, cls_visited): + """Returns the child class specified by the discriminator. + + Args: + model_class (OpenApiModel): the model class. + discr_name (string): the name of the discriminator property. + discr_value (any): the discriminator value. + cls_visited (list): list of model classes that have been visited. + Used to determine the discriminator class without + visiting circular references indefinitely. + + Returns: + used_model_class (class/None): the chosen child class that will be used + to deserialize the data, for example dog.Dog. + If a class is not found, None is returned. + """ + + if model_class in cls_visited: + # The class has already been visited and no suitable class was found. + return None + cls_visited.append(model_class) + used_model_class = None + if discr_name in model_class.discriminator: + class_name_to_discr_class = model_class.discriminator[discr_name] + used_model_class = class_name_to_discr_class.get(discr_value) + if used_model_class is None: + # We didn't find a discriminated class in class_name_to_discr_class. + # So look in the ancestor or descendant discriminators + # The discriminator mapping may exist in a descendant (anyOf, oneOf) + # or ancestor (allOf). + # Ancestor example: in the GrandparentAnimal -> ParentPet -> ChildCat + # hierarchy, the discriminator mappings may be defined at any level + # in the hierarchy. + # Descendant example: mammal -> whale/zebra/Pig -> BasquePig/DanishPig + # if we try to make BasquePig from mammal, we need to travel through + # the oneOf descendant discriminators to find BasquePig + descendant_classes = model_class._composed_schemas.get('oneOf', ()) + \ + model_class._composed_schemas.get('anyOf', ()) + ancestor_classes = model_class._composed_schemas.get('allOf', ()) + possible_classes = descendant_classes + ancestor_classes + for cls in possible_classes: + # Check if the schema has inherited discriminators. + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + used_model_class = get_discriminator_class( + cls, discr_name, discr_value, cls_visited) + if used_model_class is not None: + return used_model_class + return used_model_class + + +def deserialize_model(model_data, model_class, path_to_item, check_type, + configuration, spec_property_naming): + """Deserializes model_data to model instance. + + Args: + model_data (int/str/float/bool/none_type/list/dict): data to instantiate the model + model_class (OpenApiModel): the model class + path_to_item (list): path to the model in the received data + check_type (bool): whether to check the data tupe for the values in + the model + configuration (Configuration): the instance to use to convert files + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. + + Returns: + model instance + + Raise: + ApiTypeError + ApiValueError + ApiKeyError + """ + + kw_args = dict(_check_type=check_type, + _path_to_item=path_to_item, + _configuration=configuration, + _spec_property_naming=spec_property_naming) + + if issubclass(model_class, ModelSimple): + return model_class(model_data, **kw_args) + elif isinstance(model_data, list): + return model_class(*model_data, **kw_args) + if isinstance(model_data, dict): + kw_args.update(model_data) + return model_class(**kw_args) + elif isinstance(model_data, PRIMITIVE_TYPES): + return model_class(model_data, **kw_args) + + +def deserialize_file(response_data, configuration, content_disposition=None): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + Args: + param response_data (str): the file data to write + configuration (Configuration): the instance to use to convert files + + Keyword Args: + content_disposition (str): the value of the Content-Disposition + header + + Returns: + (file_type): the deserialized file which is open + The user is responsible for closing and reading the file + """ + fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + if isinstance(response_data, str): + # change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + + f = open(path, "rb") + return f + + +def attempt_convert_item(input_value, valid_classes, path_to_item, + configuration, spec_property_naming, key_type=False, + must_convert=False, check_type=True): + """ + Args: + input_value (any): the data to convert + valid_classes (any): the classes that are valid + path_to_item (list): the path to the item to convert + configuration (Configuration): the instance to use to convert files + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. + key_type (bool): if True we need to convert a key type (not supported) + must_convert (bool): if True we must convert + check_type (bool): if True we check the type or the returned data in + ModelComposed/ModelNormal/ModelSimple instances + + Returns: + instance (any) the fixed item + + Raises: + ApiTypeError + ApiValueError + ApiKeyError + """ + valid_classes_ordered = order_response_types(valid_classes) + valid_classes_coercible = remove_uncoercible( + valid_classes_ordered, input_value, spec_property_naming) + if not valid_classes_coercible or key_type: + # we do not handle keytype errors, json will take care + # of this for us + if configuration is None or not configuration.discard_unknown_keys: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) + for valid_class in valid_classes_coercible: + try: + if issubclass(valid_class, OpenApiModel): + return deserialize_model(input_value, valid_class, + path_to_item, check_type, + configuration, spec_property_naming) + elif valid_class == file_type: + return deserialize_file(input_value, configuration) + return deserialize_primitive(input_value, valid_class, + path_to_item) + except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc: + if must_convert: + raise conversion_exc + # if we have conversion errors when must_convert == False + # we ignore the exception and move on to the next class + continue + # we were unable to convert, must_convert == False + return input_value + + +def is_type_nullable(input_type): + """ + Returns true if None is an allowed value for the specified input_type. + + A type is nullable if at least one of the following conditions is true: + 1. The OAS 'nullable' attribute has been specified, + 1. The type is the 'null' type, + 1. The type is a anyOf/oneOf composed schema, and a child schema is + the 'null' type. + Args: + input_type (type): the class of the input_value that we are + checking + Returns: + bool + """ + if input_type is none_type: + return True + if issubclass(input_type, OpenApiModel) and input_type._nullable: + return True + if issubclass(input_type, ModelComposed): + # If oneOf/anyOf, check if the 'null' type is one of the allowed types. + for t in input_type._composed_schemas.get('oneOf', ()): + if is_type_nullable(t): return True + for t in input_type._composed_schemas.get('anyOf', ()): + if is_type_nullable(t): return True + return False + + +def is_valid_type(input_class_simple, valid_classes): + """ + Args: + input_class_simple (class): the class of the input_value that we are + checking + valid_classes (tuple): the valid classes that the current item + should be + Returns: + bool + """ + valid_type = input_class_simple in valid_classes + if not valid_type and ( + issubclass(input_class_simple, OpenApiModel) or + input_class_simple is none_type): + for valid_class in valid_classes: + if input_class_simple is none_type and is_type_nullable(valid_class): + # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. + return True + if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): + continue + discr_propertyname_py = list(valid_class.discriminator.keys())[0] + discriminator_classes = ( + valid_class.discriminator[discr_propertyname_py].values() + ) + valid_type = is_valid_type(input_class_simple, discriminator_classes) + if valid_type: + return True + return valid_type + + +def validate_and_convert_types(input_value, required_types_mixed, path_to_item, + spec_property_naming, _check_type, configuration=None): + """Raises a TypeError is there is a problem, otherwise returns value + + Args: + input_value (any): the data to validate/convert + required_types_mixed (list/dict/tuple): A list of + valid classes, or a list tuples of valid classes, or a dict where + the value is a tuple of value classes + path_to_item: (list) the path to the data being validated + this stores a list of keys or indices to get to the data being + validated + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. + _check_type: (boolean) if true, type will be checked and conversion + will be attempted. + configuration: (Configuration): the configuration class to use + when converting file_type items. + If passed, conversion will be attempted when possible + If not passed, no conversions will be attempted and + exceptions will be raised + + Returns: + the correctly typed value + + Raises: + ApiTypeError + """ + results = get_required_type_classes(required_types_mixed, spec_property_naming) + valid_classes, child_req_types_by_current_type = results + + input_class_simple = get_simple_class(input_value) + valid_type = is_valid_type(input_class_simple, valid_classes) + if not valid_type: + if configuration: + # if input_value is not valid_type try to convert it + converted_instance = attempt_convert_item( + input_value, + valid_classes, + path_to_item, + configuration, + spec_property_naming, + key_type=False, + must_convert=True, + check_type=_check_type + ) + return converted_instance + else: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=False) + + # input_value's type is in valid_classes + if len(valid_classes) > 1 and configuration: + # there are valid classes which are not the current class + valid_classes_coercible = remove_uncoercible( + valid_classes, input_value, spec_property_naming, must_convert=False) + if valid_classes_coercible: + converted_instance = attempt_convert_item( + input_value, + valid_classes_coercible, + path_to_item, + configuration, + spec_property_naming, + key_type=False, + must_convert=False, + check_type=_check_type + ) + return converted_instance + + if child_req_types_by_current_type == {}: + # all types are of the required types and there are no more inner + # variables left to look at + return input_value + inner_required_types = child_req_types_by_current_type.get( + type(input_value) + ) + if inner_required_types is None: + # for this type, there are not more inner variables left to look at + return input_value + if isinstance(input_value, list): + if input_value == []: + # allow an empty list + return input_value + for index, inner_value in enumerate(input_value): + inner_path = list(path_to_item) + inner_path.append(index) + input_value[index] = validate_and_convert_types( + inner_value, + inner_required_types, + inner_path, + spec_property_naming, + _check_type, + configuration=configuration + ) + elif isinstance(input_value, dict): + if input_value == {}: + # allow an empty dict + return input_value + for inner_key, inner_val in input_value.items(): + inner_path = list(path_to_item) + inner_path.append(inner_key) + if get_simple_class(inner_key) != str: + raise get_type_error(inner_key, inner_path, valid_classes, + key_type=True) + input_value[inner_key] = validate_and_convert_types( + inner_val, + inner_required_types, + inner_path, + spec_property_naming, + _check_type, + configuration=configuration + ) + return input_value + + +def model_to_dict(model_instance, serialize=True): + """Returns the model properties as a dict + + Args: + model_instance (one of your model instances): the model instance that + will be converted to a dict. + + Keyword Args: + serialize (bool): if True, the keys in the dict will be values from + attribute_map + """ + result = {} + + model_instances = [model_instance] + if model_instance._composed_schemas: + model_instances.extend(model_instance._composed_instances) + for model_instance in model_instances: + for attr, value in model_instance._data_store.items(): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + attr = model_instance.attribute_map.get(attr, attr) + if isinstance(value, list): + if not value or isinstance(value[0], PRIMITIVE_TYPES): + # empty list or primitive types + result[attr] = value + elif isinstance(value[0], ModelSimple): + result[attr] = [x.value for x in value] + else: + result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif isinstance(value, ModelSimple): + result[attr] = value.value + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value + + return result + + +def type_error_message(var_value=None, var_name=None, valid_classes=None, + key_type=None): + """ + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + """ + key_or_value = 'value' + if key_type: + key_or_value = 'key' + valid_classes_phrase = get_valid_classes_phrase(valid_classes) + msg = ( + "Invalid type for variable '{0}'. Required {1} type {2} and " + "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + ) + return msg + + +def get_valid_classes_phrase(input_classes): + """Returns a string phrase describing what types are allowed + """ + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return 'is {0}'.format(all_class_names[0]) + return "is one of [{0}]".format(", ".join(all_class_names)) + + +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(self, *args, **kwargs): + spec_property_naming = kwargs.get('_spec_property_naming', False) + if spec_property_naming: + kwargs = change_keys_js_to_python(kwargs, self.__class__) + return fn(self, *args, **kwargs) + return wrapped_init + + +def get_allof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes + + Returns + composed_instances (list) + """ + composed_instances = [] + for allof_class in self._composed_schemas['allOf']: + + try: + allof_instance = allof_class(**model_args, **constant_args) + composed_instances.append(allof_instance) + except Exception as ex: + raise ApiValueError( + "Invalid inputs given to generate an instance of '%s'. The " + "input data was invalid for the allOf schema '%s' in the composed " + "schema '%s'. Error=%s" % ( + allof_class.__name__, + allof_class.__name__, + self.__class__.__name__, + str(ex) + ) + ) from ex + return composed_instances + + +def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): + """ + Find the oneOf schema that matches the input data (e.g. payload). + If exactly one schema matches the input data, an instance of that schema + is returned. + If zero or more than one schema match the input data, an exception is raised. + In OAS 3.x, the payload MUST, by validation, match exactly one of the + schemas described by oneOf. + + Args: + cls: the class we are handling + model_kwargs (dict): var_name to var_value + The input data, e.g. the payload that must match a oneOf schema + in the OpenAPI document. + constant_kwargs (dict): var_name to var_value + args that every model requires, including configuration, server + and path to item. + + Kwargs: + model_arg: (int, float, bool, str, date, datetime, ModelSimple, None): + the value to assign to a primitive class or ModelSimple class + Notes: + - this is only passed in when oneOf includes types which are not object + - None is used to suppress handling of model_arg, nullable models are handled in __new__ + + Returns + oneof_instance (instance) + """ + if len(cls._composed_schemas['oneOf']) == 0: + return None + + oneof_instances = [] + # Iterate over each oneOf schema and determine if the input data + # matches the oneOf schemas. + for oneof_class in cls._composed_schemas['oneOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if oneof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + + single_value_input = allows_single_value_input(oneof_class) + + try: + if not single_value_input: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + else: + if issubclass(oneof_class, ModelSimple): + oneof_instance = oneof_class(model_arg, **constant_kwargs) + elif oneof_class in PRIMITIVE_TYPES: + oneof_instance = validate_and_convert_types( + model_arg, + (oneof_class,), + constant_kwargs['_path_to_item'], + constant_kwargs['_spec_property_naming'], + constant_kwargs['_check_type'], + configuration=constant_kwargs['_configuration'] + ) + oneof_instances.append(oneof_instance) + except Exception: + pass + if len(oneof_instances) == 0: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. None " + "of the oneOf schemas matched the input data." % + cls.__name__ + ) + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf schemas matched the inputs, but a max of one is allowed." % + cls.__name__ + ) + return oneof_instances[0] + + +def get_anyof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + The input data, e.g. the payload that must match at least one + anyOf child schema in the OpenAPI document. + constant_args (dict): var_name to var_value + args that every model requires, including configuration, server + and path to item. + + Returns + anyof_instances (list) + """ + anyof_instances = [] + if len(self._composed_schemas['anyOf']) == 0: + return anyof_instances + + for anyof_class in self._composed_schemas['anyOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if anyof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + + try: + anyof_instance = anyof_class(**model_args, **constant_args) + anyof_instances.append(anyof_instance) + except Exception: + pass + if len(anyof_instances) == 0: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. None of the " + "anyOf schemas matched the inputs." % + self.__class__.__name__ + ) + return anyof_instances + + +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names + # before __init__ was called + for instance in composed_instances: + if instance.__class__ in self._composed_schemas['allOf']: + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + else: + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args + + +def validate_get_composed_info(constant_args, model_args, self): + """ + For composed schemas, generate schema instances for + all schemas in the oneOf/anyOf/allOf definition. If additional + properties are allowed, also assign those properties on + all matched schemas that contain additionalProperties. + Openapi schemas are python classes. + + Exceptions are raised if: + - 0 or > 1 oneOf schema matches the model_args input data + - no anyOf schema matches the model_args input data + - any of the allOf schemas do not match the model_args input data + + Args: + constant_args (dict): these are the args that every model requires + model_args (dict): these are the required and optional spec args that + were passed in to make this model + self (class): the class that we are instantiating + This class contains self._composed_schemas + + Returns: + composed_info (list): length three + composed_instances (list): the composed instances which are not + self + var_name_to_model_instances (dict): a dict going from var_name + to the model_instance which holds that var_name + the model_instance may be self or an instance of one of the + classes in self.composed_instances() + additional_properties_model_instances (list): a list of the + model instances which have the property + additional_properties_type. This list can include self + """ + # create composed_instances + composed_instances = [] + allof_instances = get_allof_instances(self, model_args, constant_args) + composed_instances.extend(allof_instances) + oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args) + if oneof_instance is not None: + composed_instances.append(oneof_instance) + anyof_instances = get_anyof_instances(self, model_args, constant_args) + composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) + + # map variable names to composed_instances + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances + + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances, + discarded_args + ] diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/models/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/models/__init__.py new file mode 100644 index 00000000000..361e2bd9766 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/models/__init__.py @@ -0,0 +1,74 @@ +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from from petstore_api.model.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +from petstore_api.model.additional_properties_any_type import AdditionalPropertiesAnyType +from petstore_api.model.additional_properties_array import AdditionalPropertiesArray +from petstore_api.model.additional_properties_boolean import AdditionalPropertiesBoolean +from petstore_api.model.additional_properties_class import AdditionalPropertiesClass +from petstore_api.model.additional_properties_integer import AdditionalPropertiesInteger +from petstore_api.model.additional_properties_number import AdditionalPropertiesNumber +from petstore_api.model.additional_properties_object import AdditionalPropertiesObject +from petstore_api.model.additional_properties_string import AdditionalPropertiesString +from petstore_api.model.animal import Animal +from petstore_api.model.animal_farm import AnimalFarm +from petstore_api.model.api_response import ApiResponse +from petstore_api.model.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly +from petstore_api.model.array_of_number_only import ArrayOfNumberOnly +from petstore_api.model.array_test import ArrayTest +from petstore_api.model.capitalization import Capitalization +from petstore_api.model.cat import Cat +from petstore_api.model.cat_all_of import CatAllOf +from petstore_api.model.category import Category +from petstore_api.model.child import Child +from petstore_api.model.child_all_of import ChildAllOf +from petstore_api.model.child_cat import ChildCat +from petstore_api.model.child_cat_all_of import ChildCatAllOf +from petstore_api.model.child_dog import ChildDog +from petstore_api.model.child_dog_all_of import ChildDogAllOf +from petstore_api.model.child_lizard import ChildLizard +from petstore_api.model.child_lizard_all_of import ChildLizardAllOf +from petstore_api.model.class_model import ClassModel +from petstore_api.model.client import Client +from petstore_api.model.dog import Dog +from petstore_api.model.dog_all_of import DogAllOf +from petstore_api.model.enum_arrays import EnumArrays +from petstore_api.model.enum_class import EnumClass +from petstore_api.model.enum_test import EnumTest +from petstore_api.model.file import File +from petstore_api.model.file_schema_test_class import FileSchemaTestClass +from petstore_api.model.format_test import FormatTest +from petstore_api.model.grandparent import Grandparent +from petstore_api.model.grandparent_animal import GrandparentAnimal +from petstore_api.model.has_only_read_only import HasOnlyReadOnly +from petstore_api.model.list import List +from petstore_api.model.map_test import MapTest +from petstore_api.model.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass +from petstore_api.model.model200_response import Model200Response +from petstore_api.model.model_return import ModelReturn +from petstore_api.model.name import Name +from petstore_api.model.number_only import NumberOnly +from petstore_api.model.number_with_validations import NumberWithValidations +from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps +from petstore_api.model.order import Order +from petstore_api.model.parent import Parent +from petstore_api.model.parent_all_of import ParentAllOf +from petstore_api.model.parent_pet import ParentPet +from petstore_api.model.pet import Pet +from petstore_api.model.player import Player +from petstore_api.model.read_only_first import ReadOnlyFirst +from petstore_api.model.special_model_name import SpecialModelName +from petstore_api.model.string_boolean_map import StringBooleanMap +from petstore_api.model.string_enum import StringEnum +from petstore_api.model.tag import Tag +from petstore_api.model.type_holder_default import TypeHolderDefault +from petstore_api.model.type_holder_example import TypeHolderExample +from petstore_api.model.user import User +from petstore_api.model.xml_item import XmlItem diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py new file mode 100644 index 00000000000..a1d580fbe05 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py @@ -0,0 +1,292 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import io +import json +import logging +import re +import ssl +from urllib.parse import urlencode + +import urllib3 + +from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.getheaders() + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.getheader(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if query_params: + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/pom.xml b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/pom.xml new file mode 100644 index 00000000000..1db0285b181 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + org.openapitools + PythonV2PetstoreClientTestsDisallowAdditionalPropertiesIfNotPresent + pom + 1.0-SNAPSHOT + Python OpenAPI Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + test + integration-test + + exec + + + make + + test + + + + + + + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/requirements.txt b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/requirements.txt new file mode 100644 index 00000000000..96947f60408 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/requirements.txt @@ -0,0 +1,3 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.cfg b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.cfg new file mode 100644 index 00000000000..11433ee875a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.py new file mode 100644 index 00000000000..c484eec94f3 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/setup.py @@ -0,0 +1,43 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "petstore-api" +VERSION = "1.0.0" +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = [ + "urllib3 >= 1.25.3", + "python-dateutil", +] + +setup( + name=NAME, + version=VERSION, + description="OpenAPI Petstore", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"], + python_requires=">=3.6", + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + license="Apache-2.0", + long_description="""\ + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + """ +) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test-requirements.txt b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test-requirements.txt new file mode 100644 index 00000000000..bb4f22bb7a6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test-requirements.txt @@ -0,0 +1 @@ +pytest-cov>=2.8.1 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_any_type.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_any_type.py new file mode 100644 index 00000000000..ce985f76ed9 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_any_type.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_any_type import AdditionalPropertiesAnyType + + +class TestAdditionalPropertiesAnyType(unittest.TestCase): + """AdditionalPropertiesAnyType unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesAnyType(self): + """Test AdditionalPropertiesAnyType""" + # FIXME: construct object with mandatory attributes with example values + # model = AdditionalPropertiesAnyType() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_array.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_array.py new file mode 100644 index 00000000000..f63ca82f6c2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_array.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_array import AdditionalPropertiesArray + + +class TestAdditionalPropertiesArray(unittest.TestCase): + """AdditionalPropertiesArray unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesArray(self): + """Test AdditionalPropertiesArray""" + # can make model without additional properties + model = AdditionalPropertiesArray() + + # can make one with additional properties + import datetime + some_val = [] + model = AdditionalPropertiesArray(some_key=some_val) + assert model['some_key'] == some_val + some_val = [True, datetime.date(1970,1,1), datetime.datetime(1970,1,1), {}, 3.1, 1, [], 'hello'] + model = AdditionalPropertiesArray(some_key=some_val) + assert model['some_key'] == some_val + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesArray(some_key='some string') + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_boolean.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_boolean.py new file mode 100644 index 00000000000..e5a13891c09 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_boolean.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_boolean import AdditionalPropertiesBoolean + + +class TestAdditionalPropertiesBoolean(unittest.TestCase): + """AdditionalPropertiesBoolean unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesBoolean(self): + """Test AdditionalPropertiesBoolean""" + # can make model without additional properties + model = AdditionalPropertiesBoolean() + + # can make one with additional properties + model = AdditionalPropertiesBoolean(some_key=True) + assert model['some_key'] == True + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesBoolean(some_key='True') + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_class.py new file mode 100644 index 00000000000..befc14455da --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_class.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_class import AdditionalPropertiesClass + + +class TestAdditionalPropertiesClass(unittest.TestCase): + """AdditionalPropertiesClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesClass(self): + """Test AdditionalPropertiesClass""" + # FIXME: construct object with mandatory attributes with example values + # model = AdditionalPropertiesClass() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_integer.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_integer.py new file mode 100644 index 00000000000..0e08b8f8770 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_integer.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_integer import AdditionalPropertiesInteger + + +class TestAdditionalPropertiesInteger(unittest.TestCase): + """AdditionalPropertiesInteger unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesInteger(self): + """Test AdditionalPropertiesInteger""" + # can make model without additional properties + model = AdditionalPropertiesInteger() + + # can make one with additional properties + model = AdditionalPropertiesInteger(some_key=3) + assert model['some_key'] == 3 + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesInteger(some_key=11.3) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_number.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_number.py new file mode 100644 index 00000000000..90f4429e989 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_number.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_number import AdditionalPropertiesNumber + + +class TestAdditionalPropertiesNumber(unittest.TestCase): + """AdditionalPropertiesNumber unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesNumber(self): + """Test AdditionalPropertiesNumber""" + # can make model without additional properties + model = AdditionalPropertiesNumber() + + # can make one with additional properties + model = AdditionalPropertiesNumber(some_key=11.3) + assert model['some_key'] == 11.3 + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesNumber(some_key=10) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_object.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_object.py new file mode 100644 index 00000000000..ded4a8e8a12 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_object.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_object import AdditionalPropertiesObject + + +class TestAdditionalPropertiesObject(unittest.TestCase): + """AdditionalPropertiesObject unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesObject(self): + """Test AdditionalPropertiesObject""" + # can make model without additional properties + model = AdditionalPropertiesObject() + + # can make one with additional properties + some_val = {} + model = AdditionalPropertiesObject(some_key=some_val) + assert model['some_key'] == some_val + import datetime + some_val = {'a': True, 'b': datetime.date(1970,1,1), 'c': datetime.datetime(1970,1,1), 'd': {}, 'e': 3.1, 'f': 1, 'g': [], 'h': 'hello'} + model = AdditionalPropertiesObject(some_key=some_val) + assert model['some_key'] == some_val + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesObject(some_key='some string') + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_string.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_string.py new file mode 100644 index 00000000000..cff2c31921f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_additional_properties_string.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.additional_properties_string import AdditionalPropertiesString + + +class TestAdditionalPropertiesString(unittest.TestCase): + """AdditionalPropertiesString unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAdditionalPropertiesString(self): + """Test AdditionalPropertiesString""" + # can make model without additional properties + model = AdditionalPropertiesString() + + # can make one with additional properties + model = AdditionalPropertiesString(some_key='some_val') + assert model['some_key'] == 'some_val' + + # type checking works on additional properties + with self.assertRaises(petstore_api.ApiTypeError) as exc: + model = AdditionalPropertiesString(some_key=True) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal.py new file mode 100644 index 00000000000..958f303f13e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import cat +except ImportError: + cat = sys.modules[ + 'petstore_api.model.cat'] +try: + from petstore_api.model import dog +except ImportError: + dog = sys.modules[ + 'petstore_api.model.dog'] +from petstore_api.model.animal import Animal + + +class TestAnimal(unittest.TestCase): + """Animal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAnimal(self): + """Test Animal""" + # FIXME: construct object with mandatory attributes with example values + # model = Animal() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal_farm.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal_farm.py new file mode 100644 index 00000000000..7117d42b430 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_animal_farm.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import animal +except ImportError: + animal = sys.modules[ + 'petstore_api.model.animal'] +from petstore_api.model.animal_farm import AnimalFarm + + +class TestAnimalFarm(unittest.TestCase): + """AnimalFarm unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAnimalFarm(self): + """Test AnimalFarm""" + # FIXME: construct object with mandatory attributes with example values + # model = AnimalFarm() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_another_fake_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_another_fake_api.py new file mode 100644 index 00000000000..f79966a2696 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_another_fake_api.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.another_fake_api import AnotherFakeApi # noqa: E501 + + +class TestAnotherFakeApi(unittest.TestCase): + """AnotherFakeApi unit test stubs""" + + def setUp(self): + self.api = AnotherFakeApi() # noqa: E501 + + def tearDown(self): + pass + + def test_call_123_test_special_tags(self): + """Test case for call_123_test_special_tags + + To test special tags # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_api_response.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_api_response.py new file mode 100644 index 00000000000..9db92633f62 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_api_response.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.api_response import ApiResponse + + +class TestApiResponse(unittest.TestCase): + """ApiResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testApiResponse(self): + """Test ApiResponse""" + # FIXME: construct object with mandatory attributes with example values + # model = ApiResponse() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_array_of_number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_array_of_number_only.py new file mode 100644 index 00000000000..4980ad17afb --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_array_of_number_only.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly + + +class TestArrayOfArrayOfNumberOnly(unittest.TestCase): + """ArrayOfArrayOfNumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testArrayOfArrayOfNumberOnly(self): + """Test ArrayOfArrayOfNumberOnly""" + # FIXME: construct object with mandatory attributes with example values + # model = ArrayOfArrayOfNumberOnly() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_number_only.py new file mode 100644 index 00000000000..479c537cada --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_of_number_only.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.array_of_number_only import ArrayOfNumberOnly + + +class TestArrayOfNumberOnly(unittest.TestCase): + """ArrayOfNumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testArrayOfNumberOnly(self): + """Test ArrayOfNumberOnly""" + # FIXME: construct object with mandatory attributes with example values + # model = ArrayOfNumberOnly() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_test.py new file mode 100644 index 00000000000..2426b27b7e4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_array_test.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import read_only_first +except ImportError: + read_only_first = sys.modules[ + 'petstore_api.model.read_only_first'] +from petstore_api.model.array_test import ArrayTest + + +class TestArrayTest(unittest.TestCase): + """ArrayTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testArrayTest(self): + """Test ArrayTest""" + # FIXME: construct object with mandatory attributes with example values + # model = ArrayTest() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_capitalization.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_capitalization.py new file mode 100644 index 00000000000..20d2649c01e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_capitalization.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.capitalization import Capitalization + + +class TestCapitalization(unittest.TestCase): + """Capitalization unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCapitalization(self): + """Test Capitalization""" + # FIXME: construct object with mandatory attributes with example values + # model = Capitalization() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat.py new file mode 100644 index 00000000000..64b525aaf11 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import animal +except ImportError: + animal = sys.modules[ + 'petstore_api.model.animal'] +try: + from petstore_api.model import cat_all_of +except ImportError: + cat_all_of = sys.modules[ + 'petstore_api.model.cat_all_of'] +from petstore_api.model.cat import Cat + + +class TestCat(unittest.TestCase): + """Cat unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCat(self): + """Test Cat""" + # FIXME: construct object with mandatory attributes with example values + # model = Cat() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat_all_of.py new file mode 100644 index 00000000000..a5bb91ac864 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_cat_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.cat_all_of import CatAllOf + + +class TestCatAllOf(unittest.TestCase): + """CatAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCatAllOf(self): + """Test CatAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = CatAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_category.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_category.py new file mode 100644 index 00000000000..59b64e5924a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_category.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.category import Category + + +class TestCategory(unittest.TestCase): + """Category unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCategory(self): + """Test Category""" + # FIXME: construct object with mandatory attributes with example values + # model = Category() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child.py new file mode 100644 index 00000000000..790fc1abc8d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_all_of +except ImportError: + child_all_of = sys.modules[ + 'petstore_api.model.child_all_of'] +try: + from petstore_api.model import parent +except ImportError: + parent = sys.modules[ + 'petstore_api.model.parent'] +from petstore_api.model.child import Child + + +class TestChild(unittest.TestCase): + """Child unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChild(self): + """Test Child + This will fail because additional_properties_type is None in ChildAllOf and it must be defined as any type + to allow in the property radio_waves which is not defined in ChildAllOf, it is defined in Grandparent + """ + # make an instance of Child, a composed schema model + radio_waves = True + tele_vision = True + inter_net = True + with self.assertRaises(petstore_api.exceptions.ApiValueError): + child = Child( + radio_waves=radio_waves, + tele_vision=tele_vision, + inter_net=inter_net + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_all_of.py new file mode 100644 index 00000000000..96e479cf079 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.child_all_of import ChildAllOf + + +class TestChildAllOf(unittest.TestCase): + """ChildAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildAllOf(self): + """Test ChildAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat.py new file mode 100644 index 00000000000..34c085515a8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_cat_all_of +except ImportError: + child_cat_all_of = sys.modules[ + 'petstore_api.model.child_cat_all_of'] +try: + from petstore_api.model import parent_pet +except ImportError: + parent_pet = sys.modules[ + 'petstore_api.model.parent_pet'] +from petstore_api.model.child_cat import ChildCat + + +class TestChildCat(unittest.TestCase): + """ChildCat unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildCat(self): + """Test ChildCat""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildCat() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat_all_of.py new file mode 100644 index 00000000000..2a7aab100fb --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_cat_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.child_cat_all_of import ChildCatAllOf + + +class TestChildCatAllOf(unittest.TestCase): + """ChildCatAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildCatAllOf(self): + """Test ChildCatAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildCatAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog.py new file mode 100644 index 00000000000..dfb09213e40 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_dog_all_of +except ImportError: + child_dog_all_of = sys.modules[ + 'petstore_api.model.child_dog_all_of'] +try: + from petstore_api.model import parent_pet +except ImportError: + parent_pet = sys.modules[ + 'petstore_api.model.parent_pet'] +from petstore_api.model.child_dog import ChildDog + + +class TestChildDog(unittest.TestCase): + """ChildDog unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildDog(self): + """Test ChildDog""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildDog() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog_all_of.py new file mode 100644 index 00000000000..ca75000c650 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_dog_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.child_dog_all_of import ChildDogAllOf + + +class TestChildDogAllOf(unittest.TestCase): + """ChildDogAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildDogAllOf(self): + """Test ChildDogAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildDogAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard.py new file mode 100644 index 00000000000..975dc1612a9 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_lizard_all_of +except ImportError: + child_lizard_all_of = sys.modules[ + 'petstore_api.model.child_lizard_all_of'] +try: + from petstore_api.model import parent_pet +except ImportError: + parent_pet = sys.modules[ + 'petstore_api.model.parent_pet'] +from petstore_api.model.child_lizard import ChildLizard + + +class TestChildLizard(unittest.TestCase): + """ChildLizard unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildLizard(self): + """Test ChildLizard""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildLizard() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard_all_of.py new file mode 100644 index 00000000000..1b3bf4dba94 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_child_lizard_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.child_lizard_all_of import ChildLizardAllOf + + +class TestChildLizardAllOf(unittest.TestCase): + """ChildLizardAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildLizardAllOf(self): + """Test ChildLizardAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ChildLizardAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_class_model.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_class_model.py new file mode 100644 index 00000000000..060df39e4b5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_class_model.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.class_model import ClassModel + + +class TestClassModel(unittest.TestCase): + """ClassModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testClassModel(self): + """Test ClassModel""" + # FIXME: construct object with mandatory attributes with example values + # model = ClassModel() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_client.py new file mode 100644 index 00000000000..ab5e3a80d37 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_client.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.client import Client + + +class TestClient(unittest.TestCase): + """Client unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testClient(self): + """Test Client""" + # FIXME: construct object with mandatory attributes with example values + # model = Client() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog.py new file mode 100644 index 00000000000..9fb96ebc6b9 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import animal +except ImportError: + animal = sys.modules[ + 'petstore_api.model.animal'] +try: + from petstore_api.model import dog_all_of +except ImportError: + dog_all_of = sys.modules[ + 'petstore_api.model.dog_all_of'] +from petstore_api.model.dog import Dog + + +class TestDog(unittest.TestCase): + """Dog unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testDog(self): + """Test Dog + This will fail because additional_properties_type is None in Animal and it must be defined as any type + to allow in the property breed which is not defined in Animal, it is defined in Dog + """ + # make an instance of dog, a composed schema model + class_name = 'Dog' + color = 'white' + breed = 'Jack Russel Terrier' + with self.assertRaises(petstore_api.exceptions.ApiValueError): + dog = Dog( + class_name=class_name, + color=color, + breed=breed + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog_all_of.py new file mode 100644 index 00000000000..7ab4e8ae79d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_dog_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.dog_all_of import DogAllOf + + +class TestDogAllOf(unittest.TestCase): + """DogAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testDogAllOf(self): + """Test DogAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = DogAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_arrays.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_arrays.py new file mode 100644 index 00000000000..64ad5fd7dc0 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_arrays.py @@ -0,0 +1,162 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.enum_arrays import EnumArrays + + +class TestEnumArrays(unittest.TestCase): + """EnumArrays unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_enumarrays_init(self): + # + # Check various combinations of valid values. + # + fish_or_crab = EnumArrays(just_symbol=">=") + self.assertEqual(fish_or_crab.just_symbol, ">=") + # if optional property is unset we raise an exception + with self.assertRaises(petstore_api.ApiAttributeError) as exc: + self.assertEqual(fish_or_crab.array_enum, None) + + fish_or_crab = EnumArrays(just_symbol="$", array_enum=["fish"]) + self.assertEqual(fish_or_crab.just_symbol, "$") + self.assertEqual(fish_or_crab.array_enum, ["fish"]) + + fish_or_crab = EnumArrays(just_symbol=">=", array_enum=["fish"]) + self.assertEqual(fish_or_crab.just_symbol, ">=") + self.assertEqual(fish_or_crab.array_enum, ["fish"]) + + fish_or_crab = EnumArrays(just_symbol="$", array_enum=["crab"]) + self.assertEqual(fish_or_crab.just_symbol, "$") + self.assertEqual(fish_or_crab.array_enum, ["crab"]) + + + # + # Check if setting invalid values fails + # + with self.assertRaises(petstore_api.ApiValueError) as exc: + fish_or_crab = EnumArrays(just_symbol="<=") + + with self.assertRaises(petstore_api.ApiValueError) as exc: + fish_or_crab = EnumArrays(just_symbol="$", array_enum=["dog"]) + + with self.assertRaises(petstore_api.ApiTypeError) as exc: + fish_or_crab = EnumArrays(just_symbol=["$"], array_enum=["crab"]) + + + def test_enumarrays_setter(self): + + # + # Check various combinations of valid values + # + fish_or_crab = EnumArrays() + + fish_or_crab.just_symbol = ">=" + self.assertEqual(fish_or_crab.just_symbol, ">=") + + fish_or_crab.just_symbol = "$" + self.assertEqual(fish_or_crab.just_symbol, "$") + + fish_or_crab.array_enum = [] + self.assertEqual(fish_or_crab.array_enum, []) + + fish_or_crab.array_enum = ["fish"] + self.assertEqual(fish_or_crab.array_enum, ["fish"]) + + fish_or_crab.array_enum = ["fish", "fish", "fish"] + self.assertEqual(fish_or_crab.array_enum, ["fish", "fish", "fish"]) + + fish_or_crab.array_enum = ["crab"] + self.assertEqual(fish_or_crab.array_enum, ["crab"]) + + fish_or_crab.array_enum = ["crab", "fish"] + self.assertEqual(fish_or_crab.array_enum, ["crab", "fish"]) + + fish_or_crab.array_enum = ["crab", "fish", "crab", "fish"] + self.assertEqual(fish_or_crab.array_enum, ["crab", "fish", "crab", "fish"]) + + # + # Check if setting invalid values fails + # + fish_or_crab = EnumArrays() + with self.assertRaises(petstore_api.ApiValueError) as exc: + fish_or_crab.just_symbol = "!=" + + with self.assertRaises(petstore_api.ApiTypeError) as exc: + fish_or_crab.just_symbol = ["fish"] + + with self.assertRaises(petstore_api.ApiValueError) as exc: + fish_or_crab.array_enum = ["cat"] + + with self.assertRaises(petstore_api.ApiValueError) as exc: + fish_or_crab.array_enum = ["fish", "crab", "dog"] + + with self.assertRaises(petstore_api.ApiTypeError) as exc: + fish_or_crab.array_enum = "fish" + + + def test_todict(self): + # + # Check if dictionary serialization works + # + dollar_fish_crab_dict = { + 'just_symbol': "$", + 'array_enum': ["fish", "crab"] + } + + dollar_fish_crab = EnumArrays( + just_symbol="$", array_enum=["fish", "crab"]) + + self.assertEqual(dollar_fish_crab_dict, dollar_fish_crab.to_dict()) + + # + # Sanity check for different arrays + # + dollar_crab_fish_dict = { + 'just_symbol': "$", + 'array_enum': ["crab", "fish"] + } + + dollar_fish_crab = EnumArrays( + just_symbol="$", array_enum=["fish", "crab"]) + + self.assertNotEqual(dollar_crab_fish_dict, dollar_fish_crab.to_dict()) + + + def test_equals(self): + # + # Check if object comparison works + # + fish1 = EnumArrays(just_symbol="$", array_enum=["fish"]) + fish2 = EnumArrays(just_symbol="$", array_enum=["fish"]) + self.assertEqual(fish1, fish2) + + fish = EnumArrays(just_symbol="$", array_enum=["fish"]) + crab = EnumArrays(just_symbol="$", array_enum=["crab"]) + self.assertNotEqual(fish, crab) + + dollar = EnumArrays(just_symbol="$") + greater = EnumArrays(just_symbol=">=") + self.assertNotEqual(dollar, greater) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_class.py new file mode 100644 index 00000000000..f910231c9d0 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_class.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.enum_class import EnumClass + + +class TestEnumClass(unittest.TestCase): + """EnumClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumClass(self): + """Test EnumClass""" + # FIXME: construct object with mandatory attributes with example values + # model = EnumClass() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_test.py new file mode 100644 index 00000000000..7b4c1b6b66a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_enum_test.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import string_enum +except ImportError: + string_enum = sys.modules[ + 'petstore_api.model.string_enum'] +from petstore_api.model.enum_test import EnumTest + + +class TestEnumTest(unittest.TestCase): + """EnumTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumTest(self): + """Test EnumTest""" + # FIXME: construct object with mandatory attributes with example values + # model = EnumTest() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_api.py new file mode 100644 index 00000000000..34d207f3c71 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_api.py @@ -0,0 +1,197 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.fake_api import FakeApi # noqa: E501 + + +class TestFakeApi(unittest.TestCase): + """FakeApi unit test stubs""" + + def setUp(self): + self.api = FakeApi() # noqa: E501 + + def tearDown(self): + pass + + def test_create_xml_item(self): + """Test case for create_xml_item + + creates an XmlItem # noqa: E501 + """ + pass + + def test_boolean(self): + """Test case for boolean + + """ + endpoint = self.api.boolean + assert endpoint.openapi_types['body'] == (bool,) + assert endpoint.settings['response_type'] == (bool,) + + def test_string(self): + """Test case for string + + """ + endpoint = self.api.string + assert endpoint.openapi_types['body'] == (str,) + assert endpoint.settings['response_type'] == (str,) + + def test_object_model_with_ref_props(self): + """Test case for object_model_with_ref_props + + """ + from petstore_api.model import object_model_with_ref_props + endpoint = self.api.object_model_with_ref_props + assert endpoint.openapi_types['body'] == (object_model_with_ref_props.ObjectModelWithRefProps,) + assert endpoint.settings['response_type'] == (object_model_with_ref_props.ObjectModelWithRefProps,) + + def test_string_enum(self): + """Test case for string_enum + + """ + from petstore_api.model import string_enum + endpoint = self.api.string_enum + assert endpoint.openapi_types['body'] == (string_enum.StringEnum,) + assert endpoint.settings['response_type'] == (string_enum.StringEnum,) + + def test_array_model(self): + """Test case for array_model + + """ + from petstore_api.model import animal_farm + endpoint = self.api.array_model + assert endpoint.openapi_types['body'] == (animal_farm.AnimalFarm,) + assert endpoint.settings['response_type'] == (animal_farm.AnimalFarm,) + + def test_number_with_validations(self): + """Test case for number_with_validations + + """ + from petstore_api.model import number_with_validations + endpoint = self.api.number_with_validations + assert endpoint.openapi_types['body'] == (number_with_validations.NumberWithValidations,) + assert endpoint.settings['response_type'] == (number_with_validations.NumberWithValidations,) + + def test_test_body_with_file_schema(self): + """Test case for test_body_with_file_schema + + """ + pass + + def test_test_body_with_query_params(self): + """Test case for test_body_with_query_params + + """ + pass + + def test_test_client_model(self): + """Test case for test_client_model + + To test \"client\" model # noqa: E501 + """ + pass + + def test_test_endpoint_enums_length_one(self): + """Test case for test_endpoint_enums_length_one + + """ + # when we omit the required enums of length one, they are still set + endpoint = self.api.test_endpoint_enums_length_one + import six + if six.PY3: + from unittest.mock import patch + else: + from mock import patch + with patch.object(endpoint, 'call_with_http_info') as call_with_http_info: + endpoint() + call_with_http_info.assert_called_with( + _check_input_type=True, + _check_return_type=True, + _host_index=None, + _preload_content=True, + _request_timeout=None, + _return_http_data_only=True, + async_req=False, + header_number=1.234, + path_integer=34, + path_string='hello', + query_integer=3, + query_string='brillig' + ) + + def test_test_endpoint_parameters(self): + """Test case for test_endpoint_parameters + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + """ + # check that we can access the endpoint's validations + endpoint = self.api.test_endpoint_parameters + assert endpoint.validations[('number',)] == { + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + } + # make sure that an exception is thrown on an invalid value + keyword_args = dict( + number=544, # invalid + double=100, + pattern_without_delimiter="abc", + byte='sample string' + ) + with self.assertRaises(petstore_api.ApiValueError): + self.api.test_endpoint_parameters(**keyword_args) + + def test_test_enum_parameters(self): + """Test case for test_enum_parameters + + To test enum parameters # noqa: E501 + """ + # check that we can access the endpoint's allowed_values + endpoint = self.api.test_enum_parameters + assert endpoint.allowed_values[('enum_query_string',)] == { + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + } + # make sure that an exception is thrown on an invalid value + keyword_args = dict(enum_query_string="bad value") + with self.assertRaises(petstore_api.ApiValueError): + self.api.test_enum_parameters(**keyword_args) + + def test_test_group_parameters(self): + """Test case for test_group_parameters + + Fake endpoint to test group parameters (optional) # noqa: E501 + """ + pass + + def test_test_inline_additional_properties(self): + """Test case for test_inline_additional_properties + + test inline additionalProperties # noqa: E501 + """ + pass + + def test_test_json_form_data(self): + """Test case for test_json_form_data + + test json serialization of form data # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_classname_tags_123_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_classname_tags_123_api.py new file mode 100644 index 00000000000..1ade31405a6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_fake_classname_tags_123_api.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api # noqa: E501 + + +class TestFakeClassnameTags123Api(unittest.TestCase): + """FakeClassnameTags123Api unit test stubs""" + + def setUp(self): + self.api = FakeClassnameTags123Api() # noqa: E501 + + def tearDown(self): + pass + + def test_test_classname(self): + """Test case for test_classname + + To test class name in snake case # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file.py new file mode 100644 index 00000000000..8d60f64e01c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.file import File + + +class TestFile(unittest.TestCase): + """File unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFile(self): + """Test File""" + # FIXME: construct object with mandatory attributes with example values + # model = File() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file_schema_test_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file_schema_test_class.py new file mode 100644 index 00000000000..9a4f6d38dfe --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_file_schema_test_class.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import file +except ImportError: + file = sys.modules[ + 'petstore_api.model.file'] +from petstore_api.model.file_schema_test_class import FileSchemaTestClass + + +class TestFileSchemaTestClass(unittest.TestCase): + """FileSchemaTestClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFileSchemaTestClass(self): + """Test FileSchemaTestClass""" + # FIXME: construct object with mandatory attributes with example values + # model = FileSchemaTestClass() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_format_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_format_test.py new file mode 100644 index 00000000000..ca37b005fd9 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_format_test.py @@ -0,0 +1,153 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.format_test import FormatTest + + +class TestFormatTest(unittest.TestCase): + """FormatTest unit test stubs""" + + def setUp(self): + import datetime + self.required_named_args = dict( + number=40.1, + byte='what', + date=datetime.date(2019, 3, 23), + password='rainbowtable' + ) + + def test_integer(self): + var_name = 'integer' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_int32(self): + var_name = 'int32' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_number(self): + var_name = 'number' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_float(self): + var_name = 'float' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_double(self): + var_name = 'double' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_password(self): + var_name = 'password' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('max_length', 1), ('min_length', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = 'a'*(validations[key] + adder) + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = 'a'*validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + 'a'*validations[key]) + + def test_string(self): + var_name = 'string' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + values_invalid = ['abc3', '1', '.', ' ', 'مرحبا', ''] + for value_invalid in values_invalid: + # invalid values throw exceptions + with self.assertRaises(petstore_api.ApiValueError): + keyword_args[var_name] = value_invalid + FormatTest(**keyword_args) + + # valid value works + value_valid = 'abcdz' + keyword_args[var_name] = value_valid + assert getattr(FormatTest(**keyword_args), var_name) == value_valid + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent.py new file mode 100644 index 00000000000..2972d01161c --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.grandparent import Grandparent + + +class TestGrandparent(unittest.TestCase): + """Grandparent unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testGrandparent(self): + """Test Grandparent""" + # FIXME: construct object with mandatory attributes with example values + # model = Grandparent() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent_animal.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent_animal.py new file mode 100644 index 00000000000..cabe4d81f98 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_grandparent_animal.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_cat +except ImportError: + child_cat = sys.modules[ + 'petstore_api.model.child_cat'] +try: + from petstore_api.model import child_dog +except ImportError: + child_dog = sys.modules[ + 'petstore_api.model.child_dog'] +try: + from petstore_api.model import child_lizard +except ImportError: + child_lizard = sys.modules[ + 'petstore_api.model.child_lizard'] +try: + from petstore_api.model import parent_pet +except ImportError: + parent_pet = sys.modules[ + 'petstore_api.model.parent_pet'] +from petstore_api.model.grandparent_animal import GrandparentAnimal + + +class TestGrandparentAnimal(unittest.TestCase): + """GrandparentAnimal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testGrandparentAnimal(self): + """Test GrandparentAnimal""" + # FIXME: construct object with mandatory attributes with example values + # model = GrandparentAnimal() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_has_only_read_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_has_only_read_only.py new file mode 100644 index 00000000000..9ebd7683b39 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_has_only_read_only.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.has_only_read_only import HasOnlyReadOnly + + +class TestHasOnlyReadOnly(unittest.TestCase): + """HasOnlyReadOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testHasOnlyReadOnly(self): + """Test HasOnlyReadOnly""" + # FIXME: construct object with mandatory attributes with example values + # model = HasOnlyReadOnly() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_list.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_list.py new file mode 100644 index 00000000000..52156adfed2 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_list.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.list import List + + +class TestList(unittest.TestCase): + """List unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testList(self): + """Test List""" + # FIXME: construct object with mandatory attributes with example values + # model = List() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_map_test.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_map_test.py new file mode 100644 index 00000000000..3feda0f688d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_map_test.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import string_boolean_map +except ImportError: + string_boolean_map = sys.modules[ + 'petstore_api.model.string_boolean_map'] +from petstore_api.model.map_test import MapTest + + +class TestMapTest(unittest.TestCase): + """MapTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_maptest_init(self): + # + # Test MapTest construction with valid values + # + up_or_low_dict = { + 'UPPER': "UP", + 'lower': "low" + } + map_enum_test = MapTest(map_of_enum_string=up_or_low_dict) + + self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) + + map_of_map_of_strings = { + 'valueDict': up_or_low_dict + } + map_enum_test = MapTest(map_map_of_string=map_of_map_of_strings) + + self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings) + + # + # Make sure that the init fails for invalid enum values + # + black_or_white_dict = { + 'black': "UP", + 'white': "low" + } + with self.assertRaises(petstore_api.ApiValueError): + MapTest(map_of_enum_string=black_or_white_dict) + + def test_maptest_setter(self): + # + # Check with some valid values + # + map_enum_test = MapTest() + up_or_low_dict = { + 'UPPER': "UP", + 'lower': "low" + } + map_enum_test.map_of_enum_string = up_or_low_dict + self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) + + # + # Check if the setter fails for invalid enum values + # + map_enum_test = MapTest() + black_or_white_dict = { + 'black': "UP", + 'white': "low" + } + with self.assertRaises(petstore_api.ApiValueError): + map_enum_test.map_of_enum_string = black_or_white_dict + + def test_todict(self): + # + # Check dictionary serialization + # + map_enum_test = MapTest() + up_or_low_dict = { + 'UPPER': "UP", + 'lower': "low" + } + map_of_map_of_strings = { + 'valueDict': up_or_low_dict + } + indirect_map = string_boolean_map.StringBooleanMap(**{ + 'option1': True + }) + direct_map = { + 'option2': False + } + map_enum_test.map_of_enum_string = up_or_low_dict + map_enum_test.map_map_of_string = map_of_map_of_strings + map_enum_test.indirect_map = indirect_map + map_enum_test.direct_map = direct_map + + self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) + self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings) + self.assertEqual(map_enum_test.indirect_map, indirect_map) + self.assertEqual(map_enum_test.direct_map, direct_map) + + expected_dict = { + 'map_of_enum_string': up_or_low_dict, + 'map_map_of_string': map_of_map_of_strings, + 'indirect_map': indirect_map.to_dict(), + 'direct_map': direct_map + } + + self.assertEqual(map_enum_test.to_dict(), expected_dict) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_mixed_properties_and_additional_properties_class.py new file mode 100644 index 00000000000..4dcb5ad4268 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_mixed_properties_and_additional_properties_class.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import animal +except ImportError: + animal = sys.modules[ + 'petstore_api.model.animal'] +from petstore_api.model.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass + + +class TestMixedPropertiesAndAdditionalPropertiesClass(unittest.TestCase): + """MixedPropertiesAndAdditionalPropertiesClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testMixedPropertiesAndAdditionalPropertiesClass(self): + """Test MixedPropertiesAndAdditionalPropertiesClass""" + # FIXME: construct object with mandatory attributes with example values + # model = MixedPropertiesAndAdditionalPropertiesClass() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model200_response.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model200_response.py new file mode 100644 index 00000000000..4012eaae336 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model200_response.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.model200_response import Model200Response + + +class TestModel200Response(unittest.TestCase): + """Model200Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testModel200Response(self): + """Test Model200Response""" + # FIXME: construct object with mandatory attributes with example values + # model = Model200Response() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model_return.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model_return.py new file mode 100644 index 00000000000..54c98b33cd6 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_model_return.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.model_return import ModelReturn + + +class TestModelReturn(unittest.TestCase): + """ModelReturn unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testModelReturn(self): + """Test ModelReturn""" + # FIXME: construct object with mandatory attributes with example values + # model = ModelReturn() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_name.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_name.py new file mode 100644 index 00000000000..6a9be99d1a5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_name.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.name import Name + + +class TestName(unittest.TestCase): + """Name unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testName(self): + """Test Name""" + # FIXME: construct object with mandatory attributes with example values + # model = Name() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_only.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_only.py new file mode 100644 index 00000000000..07aab1d78af --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_only.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.number_only import NumberOnly + + +class TestNumberOnly(unittest.TestCase): + """NumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testNumberOnly(self): + """Test NumberOnly""" + # FIXME: construct object with mandatory attributes with example values + # model = NumberOnly() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_with_validations.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_with_validations.py new file mode 100644 index 00000000000..3f0b78835d4 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_number_with_validations.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.number_with_validations import NumberWithValidations + + +class TestNumberWithValidations(unittest.TestCase): + """NumberWithValidations unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testNumberWithValidations(self): + """Test NumberWithValidations""" + valid_values = [10.0, 15.0, 20.0] + for valid_value in valid_values: + model = NumberWithValidations(valid_value) + assert model.value == valid_value + + invalid_values = [9.0, 21.0] + for invalid_value in invalid_values: + with self.assertRaises(petstore_api.ApiValueError): + NumberWithValidations(invalid_value) + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_object_model_with_ref_props.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_object_model_with_ref_props.py new file mode 100644 index 00000000000..35bd3b6d8ec --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_object_model_with_ref_props.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import number_with_validations +except ImportError: + number_with_validations = sys.modules[ + 'petstore_api.model.number_with_validations'] +from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps + + +class TestObjectModelWithRefProps(unittest.TestCase): + """ObjectModelWithRefProps unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testObjectModelWithRefProps(self): + """Test ObjectModelWithRefProps""" + from petstore_api.model.number_with_validations import NumberWithValidations + self.assertEqual( + ObjectModelWithRefProps.openapi_types, + { + 'my_number': (NumberWithValidations,), + 'my_string': (str,), + 'my_boolean': (bool,), + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_order.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_order.py new file mode 100644 index 00000000000..ee6988e28cc --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_order.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.order import Order + + +class TestOrder(unittest.TestCase): + """Order unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testOrder(self): + """Test Order""" + order = Order() + order.status = "placed" + self.assertEqual("placed", order.status) + with self.assertRaises(petstore_api.ApiValueError): + order.status = "invalid" + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent.py new file mode 100644 index 00000000000..20282dfb41e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import grandparent +except ImportError: + grandparent = sys.modules[ + 'petstore_api.model.grandparent'] +try: + from petstore_api.model import parent_all_of +except ImportError: + parent_all_of = sys.modules[ + 'petstore_api.model.parent_all_of'] +from petstore_api.model.parent import Parent + + +class TestParent(unittest.TestCase): + """Parent unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParent(self): + """Test Parent""" + # FIXME: construct object with mandatory attributes with example values + # model = Parent() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_all_of.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_all_of.py new file mode 100644 index 00000000000..ca87189bba5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_all_of.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.parent_all_of import ParentAllOf + + +class TestParentAllOf(unittest.TestCase): + """ParentAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParentAllOf(self): + """Test ParentAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = ParentAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_pet.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_pet.py new file mode 100644 index 00000000000..17a4d60e75d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_parent_pet.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import child_cat +except ImportError: + child_cat = sys.modules[ + 'petstore_api.model.child_cat'] +try: + from petstore_api.model import child_dog +except ImportError: + child_dog = sys.modules[ + 'petstore_api.model.child_dog'] +try: + from petstore_api.model import child_lizard +except ImportError: + child_lizard = sys.modules[ + 'petstore_api.model.child_lizard'] +try: + from petstore_api.model import grandparent_animal +except ImportError: + grandparent_animal = sys.modules[ + 'petstore_api.model.grandparent_animal'] +from petstore_api.model.parent_pet import ParentPet + + +class TestParentPet(unittest.TestCase): + """ParentPet unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParentPet(self): + """Test ParentPet""" + # FIXME: construct object with mandatory attributes with example values + # model = ParentPet() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet.py new file mode 100644 index 00000000000..b072cff5e9a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +try: + from petstore_api.model import category +except ImportError: + category = sys.modules[ + 'petstore_api.model.category'] +try: + from petstore_api.models import tag +except ImportError: + tag = sys.modules[ + 'petstore_api.model.tag'] +from petstore_api.model.pet import Pet + + +class TestPet(unittest.TestCase): + """Pet unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_to_str(self): + pet = Pet(name="test name", photo_urls=["string"]) + pet.id = 1 + pet.status = "available" + cate = category.Category() + cate.id = 1 + cate.name = "dog" + pet.category = cate + tag1 = tag.Tag() + tag1.id = 1 + pet.tags = [tag1] + + data = ("{'category': {'id': 1, 'name': 'dog'},\n" + " 'id': 1,\n" + " 'name': 'test name',\n" + " 'photo_urls': ['string'],\n" + " 'status': 'available',\n" + " 'tags': [{'id': 1}]}") + self.assertEqual(data, pet.to_str()) + + def test_equal(self): + pet1 = Pet(name="test name", photo_urls=["string"]) + pet1.id = 1 + pet1.status = "available" + cate1 = category.Category() + cate1.id = 1 + cate1.name = "dog" + tag1 = tag.Tag() + tag1.id = 1 + pet1.tags = [tag1] + + pet2 = Pet(name="test name", photo_urls=["string"]) + pet2.id = 1 + pet2.status = "available" + cate2 = category.Category() + cate2.id = 1 + cate2.name = "dog" + tag2 = tag.Tag() + tag2.id = 1 + pet2.tags = [tag2] + + self.assertTrue(pet1 == pet2) + + # reset pet1 tags to empty array so that object comparison returns false + pet1.tags = [] + self.assertFalse(pet1 == pet2) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet_api.py new file mode 100644 index 00000000000..091b30cf8ac --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_pet_api.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.api.pet_api import PetApi # noqa: E501 + + +class TestPetApi(unittest.TestCase): + """PetApi unit test stubs""" + + def setUp(self): + self.api = PetApi() # noqa: E501 + + def tearDown(self): + pass + + def test_add_pet(self): + """Test case for add_pet + + Add a new pet to the store # noqa: E501 + """ + pass + + def test_delete_pet(self): + """Test case for delete_pet + + Deletes a pet # noqa: E501 + """ + pass + + def test_find_pets_by_status(self): + """Test case for find_pets_by_status + + Finds Pets by status # noqa: E501 + """ + pass + + def test_find_pets_by_tags(self): + """Test case for find_pets_by_tags + + Finds Pets by tags # noqa: E501 + """ + pass + + def test_get_pet_by_id(self): + """Test case for get_pet_by_id + + Find pet by ID # noqa: E501 + """ + pass + + def test_update_pet(self): + """Test case for update_pet + + Update an existing pet # noqa: E501 + """ + pass + + def test_update_pet_with_form(self): + """Test case for update_pet_with_form + + Updates a pet in the store with form data # noqa: E501 + """ + pass + + def test_upload_file(self): + """Test case for upload_file + + uploads an image # noqa: E501 + """ + pass + + def test_upload_file_with_required_file(self): + """Test case for upload_file_with_required_file + + uploads an image (required) # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_player.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_player.py new file mode 100644 index 00000000000..ee7b95a677f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_player.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.player import Player + + +class TestPlayer(unittest.TestCase): + """Player unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testPlayer(self): + """Test Player""" + # we can make a player without an enemy_player property + jane = Player(name="Jane") + # we can make a player with an enemy_player + sally = Player(name="Sally", enemy_player=jane) + # we can make a player with an inline enemy_player + jim = Player( + name="Jim", + enemy_player=Player(name="Sam") + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_read_only_first.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_read_only_first.py new file mode 100644 index 00000000000..c2dcde240e7 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_read_only_first.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.read_only_first import ReadOnlyFirst + + +class TestReadOnlyFirst(unittest.TestCase): + """ReadOnlyFirst unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testReadOnlyFirst(self): + """Test ReadOnlyFirst""" + # FIXME: construct object with mandatory attributes with example values + # model = ReadOnlyFirst() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_special_model_name.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_special_model_name.py new file mode 100644 index 00000000000..6124525f517 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_special_model_name.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.special_model_name import SpecialModelName + + +class TestSpecialModelName(unittest.TestCase): + """SpecialModelName unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSpecialModelName(self): + """Test SpecialModelName""" + # FIXME: construct object with mandatory attributes with example values + # model = SpecialModelName() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_store_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_store_api.py new file mode 100644 index 00000000000..0d9cc3dd36e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_store_api.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.store_api import StoreApi # noqa: E501 + + +class TestStoreApi(unittest.TestCase): + """StoreApi unit test stubs""" + + def setUp(self): + self.api = StoreApi() # noqa: E501 + + def tearDown(self): + pass + + def test_delete_order(self): + """Test case for delete_order + + Delete purchase order by ID # noqa: E501 + """ + pass + + def test_get_inventory(self): + """Test case for get_inventory + + Returns pet inventories by status # noqa: E501 + """ + pass + + def test_get_order_by_id(self): + """Test case for get_order_by_id + + Find purchase order by ID # noqa: E501 + """ + pass + + def test_place_order(self): + """Test case for place_order + + Place an order for a pet # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_boolean_map.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_boolean_map.py new file mode 100644 index 00000000000..e2e9d8b420b --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_boolean_map.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.string_boolean_map import StringBooleanMap + + +class TestStringBooleanMap(unittest.TestCase): + """StringBooleanMap unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testStringBooleanMap(self): + """Test StringBooleanMap""" + # FIXME: construct object with mandatory attributes with example values + # model = StringBooleanMap() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_enum.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_enum.py new file mode 100644 index 00000000000..5eed0ad6f0e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_string_enum.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.string_enum import StringEnum + + +class TestStringEnum(unittest.TestCase): + """StringEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testStringEnum(self): + """Test StringEnum""" + + """Test OuterEnum""" + # make sure that we can access its allowed_values + assert StringEnum.allowed_values[('value',)] == { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered" + } + # make sure that an exception is thrown on an invalid value + with self.assertRaises(petstore_api.ApiValueError): + StringEnum('bad_value') + # make sure valid value works + valid_value = StringEnum.allowed_values[('value',)]['PLACED'] + assert valid_value == StringEnum(valid_value).value + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_tag.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_tag.py new file mode 100644 index 00000000000..68a3b9046bf --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_tag.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.tag import Tag + + +class TestTag(unittest.TestCase): + """Tag unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTag(self): + """Test Tag""" + # FIXME: construct object with mandatory attributes with example values + # model = Tag() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_default.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_default.py new file mode 100644 index 00000000000..f9c050b81a8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_default.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.type_holder_default import TypeHolderDefault + + +class TestTypeHolderDefault(unittest.TestCase): + """TypeHolderDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTypeHolderDefault(self): + """Test TypeHolderDefault""" + # required_vars are set to None now until swagger-parser/swagger-core fixes + # https://github.com/swagger-api/swagger-parser/issues/971 + array_item = [1, 2, 3] + model = TypeHolderDefault(array_item=array_item) + self.assertEqual(model.string_item, 'what') + self.assertEqual(model.bool_item, True) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_example.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_example.py new file mode 100644 index 00000000000..e1ee7c36862 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_type_holder_example.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.type_holder_example import TypeHolderExample + + +class TestTypeHolderExample(unittest.TestCase): + """TypeHolderExample unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTypeHolderExample(self): + """Test TypeHolderExample""" + # FIXME: construct object with mandatory attributes with example values + # model = TypeHolderExample() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user.py new file mode 100644 index 00000000000..7241bb589c5 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.user import User + + +class TestUser(unittest.TestCase): + """User unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testUser(self): + """Test User""" + # FIXME: construct object with mandatory attributes with example values + # model = User() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user_api.py new file mode 100644 index 00000000000..df306da0776 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_user_api.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.user_api import UserApi # noqa: E501 + + +class TestUserApi(unittest.TestCase): + """UserApi unit test stubs""" + + def setUp(self): + self.api = UserApi() # noqa: E501 + + def tearDown(self): + pass + + def test_create_user(self): + """Test case for create_user + + Create user # noqa: E501 + """ + pass + + def test_create_users_with_array_input(self): + """Test case for create_users_with_array_input + + Creates list of users with given input array # noqa: E501 + """ + pass + + def test_create_users_with_list_input(self): + """Test case for create_users_with_list_input + + Creates list of users with given input array # noqa: E501 + """ + pass + + def test_delete_user(self): + """Test case for delete_user + + Delete user # noqa: E501 + """ + pass + + def test_get_user_by_name(self): + """Test case for get_user_by_name + + Get user by user name # noqa: E501 + """ + pass + + def test_login_user(self): + """Test case for login_user + + Logs user into the system # noqa: E501 + """ + pass + + def test_logout_user(self): + """Test case for logout_user + + Logs out current logged in user session # noqa: E501 + """ + pass + + def test_update_user(self): + """Test case for update_user + + Updated user # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_xml_item.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_xml_item.py new file mode 100644 index 00000000000..4354664815f --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test/test_xml_item.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import sys +import unittest + +import petstore_api +from petstore_api.model.xml_item import XmlItem + + +class TestXmlItem(unittest.TestCase): + """XmlItem unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testXmlItem(self): + """Test XmlItem""" + # FIXME: construct object with mandatory attributes with example values + # model = XmlItem() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test_python.sh b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test_python.sh new file mode 100644 index 00000000000..6f5e2c41d3a --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/test_python.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=venv +DEACTIVE=false + +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +### set virtualenv +if [ -z "$VIRTUAL_ENV" ]; then + virtualenv $VENV --no-site-packages --always-copy + source $VENV/bin/activate + DEACTIVE=true +fi + +### install dependencies +pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT + +### run tests +tox || exit 1 + +### static analysis of code +#flake8 --show-source petstore_api/ + +### deactivate virtualenv +#if [ $DEACTIVE == true ]; then +# deactivate +#fi diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic1.png b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic1.png new file mode 100644 index 0000000000000000000000000000000000000000..7d3a386a21026f9b15b2c303a81f5c69333e9056 GIT binary patch literal 67 zcmeAS@N?(olHy`uVBq!ia0vp^j3CSbBp9sfW`_bPE>9Q7kcv6UzxWv#Ss9tmFVH&+ OlJ#`;b6Mw<&;$T@!wsPT literal 0 HcmV?d00001 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic2.png b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/1px_pic2.png new file mode 100644 index 0000000000000000000000000000000000000000..7d3a386a21026f9b15b2c303a81f5c69333e9056 GIT binary patch literal 67 zcmeAS@N?(olHy`uVBq!ia0vp^j3CSbBp9sfW`_bPE>9Q7kcv6UzxWv#Ss9tmFVH&+ OlJ#`;b6Mw<&;$T@!wsPT literal 0 HcmV?d00001 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/foo.png b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/testfiles/foo.png new file mode 100644 index 0000000000000000000000000000000000000000..a9b12cf5927ac757b054dd875ee137c2581f69bb GIT binary patch literal 43280 zcmV*%KsdjNP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z005plNklH1~87DdzFiA2XC;)~Dpo$3~298uzpt7UB?2C zrfPXaKqE40ylK3PysV@&`KFt0-oA3>N*fHwwj}%@A;B=D*V-^3rG!ZW76I^B9@-KC zfcx*if9)N2+};ZUfyS`GYGUP72QH^lJR<@ck#YP(vYDU1^7d=5z4ouR`v4F@Nabc& zLb)YG`lepJdcUe)d-l2K zyx+EMn+;9f>WF|wWYl=$JooJLs~>;-@g90(3kED$Fc@GP91I35VIa{AEG{nY zvw8F8{&{(Mcg&voQcL&x*|~mgF?k;cfR2d?c;u0XX7umh|K6qw9ud%pj2d_(Fkkrl z^Q#~K)3hGaAP9>gNm&_?3=;$k765@>@hSL4`-^bt>E}Z6H3S6PF%3arOT{xPiShm6 zaxDJ-3;f^iRX9|27?PB=Az0cLiU1Kio9=(PpI&~}St%btePp1vO#Y+2CJ+e36c-ow z&igcf^8ESphpk+>(vvzC9(RfzfDl4>fP?Mdh4VZjMxQ=?@Y-vywQ1HodVd5oBIA^^ zFc$o0{(`%wOdh5;vMIIOAz^?JV2PCI({a~1SD@c%=Q-O+LO>I}064#sRB;W90D~nC z1diaTZ~u!W`@d9i4~rm70kQ(H1R$V-r(^)1e){R~xW99MoJK8et3pD86hIgP!cuE2 zKw1>0Krj!2pkXD zN`p!8YmOYQIAhVG#V^j7F=NEeojV=tKz%-WTnrHe3^M%2asWp7z(xoa!_mMqWY}Q5 z@WOLZP03Y>fJS6gd+L6-_xm2_pMU;s6QUk=Pew6SD!BD)K3<5G%vs zW(dGyhG_$b*Vor%uQKZ(#&3EJo6C2BC`tuPL10!XU6PE15$%lxEZWaYWH42V~ z%W51sawPu46(2nC!V5DeuUfUr0|vqe6yahO!71WUOT=$!_^lEzkVw4#`s-7&`ex2( zDrwpXXhcR>5|ULVTV`ct9Vp(p8wN`N0u~s8C0H;7n|R>dff#&d5BszgAjyyhfye?| zYQuzl7P)~zA_7|h`vew{U=RzGR~^8_jq|YOz#g^Pm=O>vK0-vWq{Oh{Lr&;~mQtD< z3pb7U```aQck$xIA)8(O?s859!zQC~h}EG3!l5onD0uj-5)tzFj^gdjP1CGs3hPBg zwoGIYQNZul!~D%}esf^w&Yd8@zhMM{Nnl``R9w@x2ZZ*~*#ZkvR)Hm8k{Jw4%Ds_* z$;x%nd=55+a{@C-w2E$p7t_Yzyp|mh04W{_)JaW}5k&$^-dv1j%iet=9QcJBrKP3G zul;AAe59n;S34~t9~ zEFtZ)M?n3~5bAM~AwIo!RWy%-1cL(r1VNGnlYn7akOrf)GJxAQ&c()qdl3bxh+xv? zaY%!)Y15{}xVTn3!@D6c3)dBnm^yXpTpiH#S_q-mffd$D2+fFub3>?FYa?6$H8k5| zVdw7RsG0_FBcKr(jRr8Ps;XKhCwDra;|SXI(3ZxzE!tvE>Wye+Hiv+O1rubSqJm)u zHPtID5FKFRN=ia@b~e(|(~y#! zgcdDZf{1YF;32GDy&A8)@(<+Z=K6xDLb%4hBDVp{-p#q8d-v|IHFlM2|6Oo1IyP(V1Ssp;!)20KQ?e5i*8j_nrMUbJow|Mb<(Fq%ef3rM zT5Or~=FR)pZ>Rijgg5(9jZ0RIWf080a9^L4l!UCl*|_40ez>StFLdb8p~m0ir8%$Q zfj>@lVkTY?)1R4<(Hn~vzd;fAq?Uk#nayq6wq3mR?VM-+^rt`d(B|T?qTEA=4n?=L z)U~~O^_r8GmiA_ReC&>s1*}um%GkDT$Hm#1SsxoP5CB6EIjm121AjelIQpJ`E+7mD zutOKG+iO#F^S^BSFXrzoK!AkJ>|)2lVP;I6I1#gE&GN(&T+j=(7*K6MGI;%DW@h4+ zTW-e1mt2gvxY(2WE+a>b#;2ctis0;tdmR#+wros{i;LSC0gdAX4c|s)m|MTy*6;f3 zuYb3=xHtqLye40GlQMK63>h*6Lx&EX(Y0&Ww-b{S@(jZWoNDFEHJ^Bx_Q8kD-kDWJ zMQXhoAV&{_h;i}hoiU@!wTgd1isBhulvWqRkN^vbl0X&4teb;f6+bH1#dc4ES)=Nn zxhJ`l0hO7N(#_Z~g#`-zGc7F*lP6EY)%~xA5ViLmD=VweDdns%*I+}K0G@pEi8pV! zam?^Y%Jl@nLrQ7Re{I3sDO0A52uGChnvT_59De$4xZqS`Vj_O^t6#0XX2{@QCnY7U zG7O^vKb65S8C;c@SAY@Mj)Y0-gbuI-3;>c4XT;#0UgOcqXaxg=Dg+>4_}HFxJ_KQP z$u>;b@NeiWiw3UHf;aNT4lK*EfdeoM!}(jE^hAWDq$CU)GzjG3o9p zm^W{p&l>W&DoII6$X}Tk6^UsaCt&E**~1S$R6cw5oEUdv4IigJ=(W}OtRmqCJCGW%pz6&LRUNwtwIgJ4){{-&Nc2*b}z zM*!rcO9O@kaouO^m3yRsKrk@*s|EPryUk!hFkslOQ>gV2?1F@&cmqIob|$7x`xCl! z?OZR@U0GR)PAO*xU9@#n@B(vg8SW4%UnK3K<2K0_Q%PAOROTvIr z=K)aX8ttMsB7(&X3Bp6)yp5%M*MkN7;uqfHF@MZU-RIV=TVu+UDY*HTn;dthA;y+1 zU*WP#`*|ql{+P^=Aw%%O%;y_z7NyapT$$M%KK#0>mHDfJHoOcIyC5gJUcH8aKy}|S zT$N(@*h#3_n~{-$M<0FkhOVhy-aJ|$wJ`%mWo2c{yYHM-viPkfh^it~MiC54Sz{Im zL))d{(Q}5O3IUjGC}yZ&+sZKNOs=Axs0DCkz+^(1aj)pPvAZ~a)8lHsA7pI zC>Mi+NMKrjLogtSA&Fr~VFLo8W3xC6I`e$I_5C{KMhSwDminon0|ZsJf9tPr!yoRu zuU;}e$20o(?~i%&<~cs1TgRf-;J$tPQroo)FRmQ1G~j0=rX+Pb;GXnWSnEJ9?vW!$ z;?~TPKKR}5?wOLAo%Od9(Q=SdngNFEl8!k%lY-#Iv!Rzzy%FfRI zTLd(Yv2h-L@R0*EXU=RH4m8v$ul^n|U;tit@wpRP5S5jc`2346F?a53$on)GMMXtn z!5|#ZBm71TP3a~kCSua0NpFrCHR>0_q$5NWkW!jL2pPdY=Q(z4S26oO!(gmt6^ z3BZ5?UP%Bf2{sk5=!}U1#eg%{x^D^~F|Kef)|72iKxw}}vy$~%yQvVZ1U?b+UHhQ zR^q*P-^UwoEJ99BPDort|6LsyAUI|c3?NU({Rzv3&XR zX|rd~j`3O!p#bDh$5pTCV1xy3H|OWp#QTo40(0 z7oUF-IXO8fD=Tw0qBmx8H2no{;I{h0C?l-35Z;~e6WBsCMFK|?wylYKB3L+?2quZ& zcKSJf(XNj}A3r%u(jyj31h7DrZE5JaGoa|`OwzFylq;gZK}b_oz}oL&*_s>z2Kudf z8l`~>pExlDAuB5juP>b6s6k`eV~^vxXP@(}3&;9n#@6lIS~qJJRT=?}Fr%WPGXCsN zXO#r&E^3!VFS<>eH=Z>A|9D1Tem-W;d9SD^q0BN7_04_Q0T*R5pR2fw*00xr;Sh*rE?D!uR?EVa8 z)*%FlVY1=0JqQSi1A#;Mc>h=U=*O=yWBY$`ea8!MTgOY$(uh$ed_cLbV2RSe0en)j z6(8^W1||~%WI-CLX%n*mguwI9zvuyVMtpocva+%;e&Tp!^y$;!>DRM5b*g49DB#$< zdGj@m5i}ay(vVV`NeRhS-XKu0sTLa>i;bHK8%5e|_ny7@;~)NrWy_ZNz%5j(L4*WS zL*10>>CeX^r-jR&c*SCBYISH9sQ&$-^M+zj+f)#Hee9FW6dc@zsoyNc*N65w!A?(~ zM%6ckExVngzjQoSMB}Nh*CC@-3Ic}2t|R4`wfz%(T(TJ@fl845dTpJm=1r`$JQzXU z>izROYSbwF`7e*7S;J*m_9t{qIm1gP^isUT>73s3*kaOM4>0=!4h z=4kgwAR{Bg7gQvMPYfm)q?xPmPS4+v4R;7W?j(Cg63}RTUh!$H8?Zw1( zb5Uj;h5-|j7$ohWD+E{qAl0Ew3PV{6f&eQ37^+9CfQet9bt$$V*pD~9UkhP#OQbL$ zZ7R72IX}osUs_xTO9O`L0;d6U^ytx;KI5r6u{@-d*t>6^Q`o1oJTWbr?>|ye@kY-J zdX4v5hgzA;0wXCY2?eWi=_d&q!NB4D{kDm>^O7Y?>-EX!50Cwi$*nv=`wk7OChYZbh;9P z1p;I_>fc9QK=uYEX0V6`qYA`8nRNtXzIYjXj+B5{C@^3NDHzO3do*B3m{PTIguPMJ zdszSrFqx`tqivb!ir3(5QWOc5m9dX=gO!CAAj^rH=rVq3GhBtGl+&GlB(~LY>m9e_ zfj|D?m{#WUci+RJMQ9~`M$?V>Pi+c5TL5&Dx1wcf2vfBt;cKUf>CPnZj zvqpLudNUg!SRw$TC`|wQUHoU?Drb{ww@uZO7zh9u+O`|o$DEGDW^veAQHGsI%J9+t zEjVNyR)-3!7LFDPz&@ds-iHN2ges8J;viVo&o86kj|sWu_Uu>z(grRAgv`u7nE%Fn zA7EBiR^rL0ren#QOHfo)6iU7$Wx*)RMpfi0H_dS7NPrL^d!C%Wx2`ToxIQqFB!&zb zf~WubOzUtm4X0%GB=}2ufB*QyPwop2;CWBx)YQ}_1sM9;$B(-OWXxEqy1)o@d+YVTK`8cB6O8B(*45H8!eQ<-2k> zB!DPpSdy^&NGblaZ?&y94oGR)B`XACfeT}k@Zfm^(6L!-0K$oZ2uPH4x(rWmU4bQg z*8!%0B?++O5rPZ^m|++utbhe!5L$_5xb%#3aph^}qD#y6Xd4r+tP3d}>txfx-PnA1 zFV>W9$A5qP1_!MQ8)(Q0oT{h~BLIQ?+yYFR@>@JT{YhDnzfwH))O6(K^GZiTI6c9onE~+K&Nx1|=&+Ji+bg<3u(5EA->njZ$!qR<(n6)b(rBw$YSU?b? z5)x4mkR+5u094hir0N;FN^?X4LN&# zJ9gM{09)8bS|CFpwM9D++nEcNFvC#Yt2=inAR)+Y)V$@;UNp1QtChrvvfpQ7LKb4p zSk?3h5{C3!GJB5vh=;#^4~zgz))@r_0FoqHi{|*_c>{698C{g#CkPA+mI1qb-ph^w zBnT!HxlB>gl~}SA2I8Yy;GRyGq2C$Fn6mLLlv#&7@ew=bAq>D)izAzXs@5_fgq^M? z!<`C?%Pn1P);cVg0{N#8&JV#76!t~byK{(|e*ufNXCD8Lrf(I{>qHN9J8 zhu3xxbk}Z=UWS0Q{cRB-ToB(0x(-FxdDJA8tN0bFbs|Gz^^e6$K9K@SB8LIX=5X|B zmF%PyEwH1@!K5sLsb9a1vOp;Wn=0iB3&PHR#G5VfV%iPp+@d`s08=n5Ettfx30|S< zpfX7OLjePvu5cH{or78FH{!PS|G^LPAcP>rJMmOiyG^5%Yorgi#OT(zF#at3tj*cz z(d`J<8RBho9k&4l%9KA*QwcSBfG9CaCM&b)*b$eOHLrcCSK-JOopcotgzK zm0rT)#c$#FzyJNk$!8^hLa6_~J`G}NFtfRN^X4I5p1of|TA+Xb{*hf?%cHEU+@4>h z$W3;e!+;Q*nU527_i?((k4yaO&$w_lp;>sTZ0R-5BX#rA52qxTp_uVTRsfheTBnk<>;I79+~mz%bZmrIPD*SVFlS0Vy%3C{Ky< zDAa;9Y*|4DZcoU@g|TNTp=kT`H`%DA4WRbjd96BP(%JpgBc2qffQ0~Aut?yk&cm?y zqT4a~tSfPDtM)bl&O|^8r9%SOa$=G-`+U!R(4x)Egf7k7;pr~J5N9?AJZWK_y3Q|H zh0@Z}WbeK@GQ8QvBJ;Z&yd&1&DiePox{@{rPU=Gl2n7--)t7EvVZU?OVln&?ws z_ev2$C`}8tocFLu*y>smTMv8(iy4MZt`Z;!0AC&c4*BIfRCd8oj9_6Yle}}Q_86O- zrQ#))1vZ3gG;I^MYGVsn%wRGwNOzx;PF1oBnCjFpv(iJY!TwMTR@PP@1JV`C9(G0=;-X^QEDhYO*5Wr7 zPyR``Cjej=M)&GYvJ=sSh>V(zwQJXg5a8{i{XoNGHDh^ll31xcTLjL(CGL5{{0sOTNGXwB{J$Q&g8fxY;zcN@stGD7>EecF6kyP0oRIC+rsfypCqyYnjO^0@2Lg4}wA1Q;yjMYCDIq?8V02_*_N`i64Y3Hf72c$Nwu+4a_ z049xE5DAh2dy^{g6AWB-+PR2}ic#rj2@r(+{TQ1M?SZgm1^@|*$suP2q?^hOw%n=( zEs}~!YlBCnDQ)m2N3FfN8Dn?pRv=`s(m}Od{rKYv4b;Xk>v@p|Y(#G3i(iwfgNt}p ztHdU{#ka1<<14KGlDoSGG7 zS?I4O06-ABv}kA7_^bCM7`A07K}6Q^Souv3G&K4drV+<>!BDtpeI%w)HzPSY8M(Q+ zHYHgH;grG^NZA%{Nw+OVQG?nO!NS(FumhNaFs5BktoUIwzCQH5;&NCLWT=x{2SWe% z{Wl)vE%lfo0Tu$Co1fv4RIFQT3jl;=yJVIU0lMI{WUMaVsld=uaTI0?#g#u|){g%v znM5cO*m=#{;>N^Y7;;8;FruNFGgyjFev-z#rmI^*2|*eRB>^A^hSf0ZNYp1-c+jua z(Ha0<*z3Z`4zGjJty@=h(}nQ4CnbDD#TYEL7^N1>sbQcoKyHNtCp+I*^E?777pp5^TbwyCJ|r zxk?5M2x;NlLwoSZ=A{_3_El^-xZ84?LQ_#2Pk}Bi z+hbPx4QL@uuyF5j6#*azh5%c3z*6%! zoblj#3%2Rr+$rak6e za0@y&Z|l5Y6a(OZ!@Pv0$Xd!haLIo4(b-*-u!1v6jzpi0U{dHtO?J6HNq{6wsLgA@ zKmdf&z#&ZBFdv%_?gr@OgDym@=;L5Sk&3Taw%4eLaAegd8?-?{gNOpsk^x6Zl_-SZ zrJ0M7QM;pk`}U#2#ZoaGzdf)|=|Ttrk`@GN$hfoxdUgNRfNh;b!`*=Go1KP#pFb84 zpECsQo5!OH0RYO(Hv+2rnldcd(aSXL3`w1@N9i731_`^W7T6jnRW&6x<5Nh>(HfOd zO`l-PA_7vyZCI(2l~*0aL*Fc|oj5J&Iu`ZQgeL|h3DMEf2kN`pwL!>T3_cvJqv34` zw0!xyksV$~LBFJ=BwqkfX>tmD@WWnR=oqlAhv94nl1ihrKC)=Gh>nW61ng{)!2XI7NV{1z zNrq+E!-@zv6`;l ztXZ>zr+gq309v$YQ4-EK)+sMm7Nu1ciZ4KnDo90XK9o!~vmw;$#AixF)CM<$e!}C(n zC$+hM9Kj?hQ~=vH(D?ZHZ@oU7TXSN9nNVC@97(&@(YW>YTcHJxwaS$= z)M+|z?8oXN=bf;o^c%bA z&nDm5KtEx^Efq)GXQxykl!(6Zo^(3sr8FMYqT91)Ph^MJ!RXTYJjBPxyRi+DYGVt= ze|E3NkAXvq)MXb)DIeY|qo+(}#msb1YRzaA?AZ)<^%d&=8L!toyBS1ujdeVY>km}!;Eq^bv!|P~_88gP=MUdUP&|-;l zs{#*y^RCj?ly;YQNY%y6(D%!7^f*<4l}jJDgd5lWx>?OY?w~AM~fuS-MtzXEEpgJK(K^#dc*XNO?IBg zLc)+htZ0s2t&&tr0&;_^78vUf@3uKCyyN??@s>wG{c31!wn?5-$-H*ug_Fm&qF z>623)G(4u$hK!7iYJ+tEF!$g8iR|t=8u$MGcfN%yp~P}XTKMFLukg-yg-Rd?0+vnf z*PID5ge#B>Hz)@H7ORZ~OFA1tse&tT@q&<|OsjwI5tj%9q$t$V_Sa$IgOaaME)OX% zl6EUa-K*9xo$B0^wlqiuG)XcJScmZ84_`T13xln2&skei3^r^%4Uhf|133HKbKXB?LBkuI zv41ZdHELv4aG=Kv9EF92kTMe2sEZLD9fezOz16Yw45@eIf5iww{E@tlm(5DW=TXv zS=m_|l__g@OfPoa6=p`x(wxW+ucPtDseeFR>v%AP6CW^jX_&C^(B>Tc->%h)k6)j$NRrhKurGcoSc}1 zW>L`xPf5_IE(Mg7l=y}hAp8U`wO}53r1OjQa-sM z1(+C5Z~ZUEZFmi<4r~K)mCB$9R^?da61sGSsJ1X5RnwqK!78gF2~~!~rbD|hyXX^) zUjGl=_~k43&+a^w1rFNl#I0ntOnXh(r|N@WFU6KayCJ0I$OjrMYb_;fFmS*+gehAV z+106v=&Iv2BrQx#xfl|*FpsU`t~c<1cCSJ4ky1sB3rJYPRY&g~mtwmb9MHGJKLTKhDy%O578BRa#rTa2 z@YZ+hvFmUtm;_8q!09gUQ5I)bje)8l@zsIv@y>Va@aR|XVEC#RasAp?@j~&(*m7VG zED#K7!pX{z0l~uQccOGc0}w1wW*x$W4X-Snh!Btx1_5hIcH*gRE0nSrTaZzJuv7+x7`XKGb9^1s*e>f= zfFpdsr-R3enJV$|_uqnT?u&X)m)<{U@HM~Y2B=b3*V%x4h+A*Hm6yEvPSB%nO9N&? zQc?n@PW>Z(``h24w6xUs%-e3e4O1VuKeGEza@>8_WGq;)z|&rleLlAiIRUN|D2fs&&JdAG+d{=G3Tewz)%Cx7Dbzs0ifGijiXl1s* ztaRP`L`eWj4P4Svly7!Bx9fO=fJBu5qAfU5e6X#huMh3ULtEalc_D1OW3VeqZJ}Ql z00_O~k};q|8WN)7Q7RAPlkdL8;_ugjpF=t5*+TKIq9`H6soBf*XpL$M^7EHmJAA}oM{L$UVcZm~ON8;N zmTTdj#Kc4ttjvq-`dS#1?w*2q^X54l%Axo}k%@GNbxE#}kA990_7N-B!jMYy!L&=w zz4tRX;LWa>jIZUPPE+a*>tM?cvKp9@aw%?1=mVBf@DZh0cdl0(%LKWg0yiE&cI;s8 z&NZ01^AnU=6*f;qHGZ@N04o3~44X)$;w|p=s`ilTx)=r+0b;wKn?w{dm<1O1o`8g? z(~q$~EG1`10?|^U%2ZjRHKp4yzHlzI9FKRd{_uxCto`+!cbwl)Yo)>56971`bLWQ@ zAOynud$uN`w>Cw`JD3^C$;px3UQ6TYXQpHJ>{-xq`dVGvwAqaem1;FWcE3~gJk=yw zJzw`KVOB8>uiF{ydU`j3e%|QOqp@Pee=%s#Ap4MDSg5j1c-8aNf`u7dS76lVuVQuC zw+>@e0gvjJBBVO;Ez&(*0n1_#RCoI?%8D>?{l76|$Ga%w!wzU!Hd~e10-M4COQqi_ zz-)jh%I-p^tQ!M1<(`$$ux|1^>8yUo1PmQq_O?`_fC9A_Jrr~=paQ@(Lk9o4LE~W! z;ht#ggPF~Q4vAGlxQb5xQ^y4ejkubb$82HNteLoG@SwQF`tnBPl5fQ>XqBgRU9qi*NP6dLY)VQ)yq#NY$>B zCU;o^NQgcIV>{gJ{p}T9v zbSM2R6h&TGD#h$|wbXhIIIS0>U?RW)J4h+e|IBnedhS36T#n_Q=<{3Hm8@&Zw`1J; z|MQ*g`ZJS~l90bLFG}y9hUn*7FQ5_b%jw6S|N9H;{`99mrF-2D*Yx$|{e6|N0i>j) zATR&Zh@NO2jr_a<+;!L8o;n~;I|Ar>38gXW^eh!>GwbxN-Obh0(Mt{L z@A^%({cV^TS6?*%8`f=r6sj~`7iqIcCjW2}aqJH+{c9=o| zfp()n288WyX|6;SDglZ@TJ!ek5EF-we)tN2RIUfRaW+6vx&^t}4gqBqkLi$sdpcd| znhnROA5-9^0-uHys4^rbuA7V1<=YU&Y7Sj@knz-0PrZ4=jn@x9mg|2?#WaHd-nw;r zzn^9IU7`NX&({d{pp?I>2rjEve}?uQ+C_GE9gp3+_uz@YJc;Ew%j`h3@b}%drSddO zk^))*Ov}*;#KyKn-@bh@?Al?t?9xjR8yj2GwS&o%euvjyd(AfEEmt(h7Vxp`^d!iz z;|pq|McFMP?MhG;oU|)dO}j;;zHXBZ#Zom0y<4W>$!^yo)@+6ke)tMcZhH^kR~%6F zF0kD$Nw5sJBG&>VG5R!2I_GlqYkjU#?UEMYp^qOera^YIX;TQS*uMpnHoxJxJp%q7 z$J>jxH8%_+&`=%Y>lHMr0}p046FVkVc~3L9B9QEp%JKons8OTv^fS{VJG$OomvU?< z+<^Q~^H5k=h#$*J9bSeqpH%>}`vvEtWs4RVG-x2sKC2U=qoYsibLYJD3jXrclQ>j* zP!)pNG-`&WHax)>AJH2*N_BFwCHgE!Do+#8ba9xnBm{0tz8K>YG7!bls3eIfsD85_ zezzGP{`eI>E8l@#6(!DL7Hc*`ued~9envM8XqyH@3K*oi+1m{fj``iBt;Noyqyq-8 znS_wH|Ni&q*E~M$v7TN_!;NM5M_gPS zHf}16xFtWaaip>mH{S3I^9}sp1&wy=U#r#q1p) zD`qS!>O4GPSX^A(T$ohR(D$O=Y2@MlzUG>NcLi6v`T;{YLD9u;y%_wI8K|tR#JkJi!{7e)EY`1I z?@LU5bx>8`7w@G(Lb^MpJETFnk#3NdM!G>jx}>BVq`Mm_K{};FIt8TRZN9(vW}g2! zbBA;9Is5Fr)~A+y=vUndDj^{fK-#>1B?WC92zuyE5g~g`aS7_gTK)jYQBG-L-8+VU zT{xY5m{H@lOGA8yIn&bQ#I#ygNeI?lXDI8>NV~j@5va-JsY)S%@43tIQdrYxPkQ9! zrtcFHUbl%+5kTVy{Ft*_qvYpjs5PbRBg2b}>hS(&ygy|gH`Tk^aevm2XOtryOB#4{ zvp@#K4^cqJZCURyk0ufPva{OTv$*tpvmdq!V!HxH2gjXTHX#M=OtcD2xmT)kZO72z zrfxZE>}1HHCT}Xkn0*R}=-D|fPVcZ;Pi}@xH5ge?h-i&3q}+~I3E;%nt?s{fN_9BR z_vsMcjdXPyZ*8aLRLiUO!@|$iym3wTeez}JQkr)0lmkG=|A5P75``qD%M2jS?_D)+4Ltn-%%yzK) zvuHxbm>twYD^=W^GX7wjP7fr6Qna>FHCZ0lHI~ID?_LYwH=Eq#CG3YUnHRORS$c_{IkVtj&3X;W!{-|KO9L8#3SF^o$1N$wkRq*um zL@XS1U@BO5O?~QTYQfB3mF4B%S!ha`B}q$Fv~ej5-dZMo=TujCCnrkyGst7NO}xF~ zS{}#0I$h-O1D`Apb0>T>1a3()e8oyubW@sT(C%>8bfm{14n4yC1J?9VQO6;?>?({4 zAR`(5Fmo`*S|?&Vu2;RMmm{S7r>T#5I_}2(B{V(EW`^;7esK?tJrSVjz(vBMl>Ek$ zEfxCHXY|Kdb5c&*EySifo>yJSWP#sJ{oQYxQ%vYM_@AX{05|us6|5iOF;xE^yc2|| zr$&{!Ff^*&;!N|R6J4K^`n+#l9g-RqRo>U%FW_^Iyr9odDc)4C-u}G$cjzD{svatvZ_6Cb}FJs!bMv(djb; zrn9T~abG!JgM`4<4r#0JwFu&dC*N<<>a&0DA70_4nkEg47RoIx1mqWIO? zvKk+|jo&}YBSHyw?V2uEKWQ8Z{>?w2p@Lh_#YSh}+%k<%T~O5_e;=xkg<%35LVPNI z)g+v}h{iMNg%~l*+&+5^`YP271*Nk*2NSKXHnt1R!nLJT`G!(rJq-E+54x{ehbk;F z+-xZzfw`7$gQ+nc6D^W@dPKAKX?Aekp_BnF9Y*-_ovc5~kF#@{|4KvT!pkEFLRIup ztZn=NJhU~^kWIzF@M@*CD7U?RS*?5jPgJ+ozSqw-IzqO8$M?bwySI4QrLyr^>DzNz z3eB#Rq(1Ah@w3DPsL;eQ^kbExuQPgO16eBg*K4Q8#7;HoEW0tFr(kOsS=NX#|Z*Hnzoo1vM_RM@&^Nk5WcjQNh7M&a; z`Gwk7!bbyGJKh(C<+JnedTXKfb7b=vf*9o{CpD7>U1VT=b>&|5J?*l2UaPV{*r<)y zfn&5wrd|AVIhFjN_Gq*ms;Y|?UvO|PF3w-2rC5CoKUSW&dF-AXtPXv>pBcWn zY0!BS!BD57x4&||M)WN!tF@Y9r)0I3jz6mh<)UVg^l+mCR;xgAAGx5YND4y5L1?Cb zb-}2~?6Y;%Hgl&&jMlKi+<#;Sqo5iSS8XzKFKe>Up&N|V46E_Bm25Qm_X7{2L?C;~ zGla>Xm#*BU`{sNrhlX-Sm?P&q5`^vQNrc6!z-yum^iZ>$wtZQ&;c?R*p)QnHGYe z`sVm(>SLn&KGhj@XQWta%IgyI`q?%h&|y%Bh>*Sb6^faxtQY~}JuZBI6lARN(IJ>m zSeVrJ?lOjHWyq=|9&O!SJgjWh!xu{U!3qu&3oDaP8b?QNE2EG~T%YC$SKdu1eCi0@ z4ZH8Fa8lIMV^uHSVORIMP37A;ibyD!N;kjPmBX0g>)-`>=%Xi?K8q10NB^3U>deK_c2^3e-R8zz zKNoc}QG#T$W`AGms-U2-Pj6$r%yaH$SZgMW4`pI*{bOL@!}Jbnd=deHq6Hi0zoW%` z#n+H-g5vC$y}i8#NEY;D*Ad+lL3hXC{gXr26&kHl`>Y>wQ*8N@_ZVZH1-Pv7PkIDG z{-XE=_V04Jh1MeWx9I$vX%YkUJZ{h)uo89M?a-oKSPKF&d#PrF?4#sOq(ehLf8hKf9d{!dWUqa^zFS;>~dhihu9H8e<0F(%r#t(MBPs+s!~~ zt@{Q{W_7L=vAGJ6AV8>3wBffnA@j+?!a~A|jzekIX>Pc^c|Jslq}p+dfJJcw=z&{V zm&H~Jn4`gCR#Q<~-?M<#Ba{dZgh7x>)&$3GD!>V&FE3r_8i;IjyY3FkgnD%dT+Quf zV64JKRaI3rtFwy)Vh&kF947*X4#J{_N-Xr97ip$u$244AnP=4W^`jype%=@}=2wq;B zTIT10EQ2<0hD%QIQHDqFd$eOpMoJFKE&P1t?A5l*jYH;`=~&);G$^Logbg>$@uR@q(uLuCjG&H ziUvQ6&|Z^5*F&Jvvkemy!`a#SgP`VvER>Y1<}1$h1~kGRvZ5{-$1^D^GhllLR(U~P zaO2)irM`zJwnnm$0>AFB@ULtXqzkiuwyv5He(iI5wB zTnuAmU~ty=*7zb$x*pej(t22gHF@c{5s-hRvvvVgiJ^^lOPU#;JKywJT8^d$+uV*H zfGuW5tl~m%*NYH|BtZwkzC9<`e=Orxu#!OVO)c@u?c-ozWOO<`J?R6&?I50(rc5gF znZA!66Mai+iz12cZ1%l3pTE+rWfGE+b>)wV0+ay=zhhQf3mjh0qZ&TzceFxC_}#)@ zo-hgmdFdH2S{om?x(<#1>btu-%ww%@H>8$Af51GVNOD!RG{iw{LrvI$y& z#5r+~+oVGWYwhW4HZld()&`W9-7uSkK^sj}gigE-LZjuAa&f9->UsgX% z!A7`ZNpxvC2NWhQ!XV=Uo`VXM$_>-)7SdbwUAX4hJ_H735ur!tx@1vu+lbJx@_YkZ ziSLXYerfEHa#780T;1^c(I~!~$cPlivPhJQsvdFMyMb5^7s9@PyVCCh5F(-yav2ncidrss8az>N^_=qCzp$vh1m-7Z0> zs>vLV@xrr(M6!&TM5zDK+Vf|UGB#pH5O8zu{zc1Eqp%7&~kx z6b0DgDcIRDzJFg~^EflEw^_p#a6e(___I@Ue&8C41*^dl=@lzY>S-qB6~qxHuMjRSF5WDT-))xH34|O| zzJ`Q{BejwG-E2rpMd7m>An-y8rV%Hs~%9IH{PKaaO!9MYDxFC?vk>df$gf z1w{Bl#L){-0#INQH2xJ7C4UC+vG}V%(~d?Zg52kaU6D2ZxeI#&0o+){ba?b!08oTQ zMn;zZ9V$suH8hOLHuB_lJ6hPlp93y$WZZyn7{EWLW#~%)3?GUEQ`NkjVZpIG6@GUW z;ahM~j!whXIjYlin%6xqj&hNQv%a_9|BenjeGeNWdF_6?{F*A1H+4H%4qsob*s$6j z`LsItH{)99x#({%xU2uIrB~wkGK$KQx*r)fH$M|UZhmBRurFhtG z$Yu+RK7`Cr8qa0t+eT0Nc8M*O16eEH=Z8km@F3(um>l?t z`(|M(dyTR@@>Z+pIeOdLU$OmkEC-eRR;x`_-+*F>V$aXQ-rnBajfHdx==Zu-(?!3M zTRRcIetQQoUCZhank&EEEb5QMQ~s~qh-vG>mnw6--NGXN=XzIc&$^2vg{lQtrUWNh zLjx@*KT_lP1kGgBNle6BUe)9=^nVLzA&bg;2k;b9pMOI$jeFt&lQ{=R9S5aA6VzbA z@b$W=j;G>^6`Ooihq)jwQ^x#4mu{5%crasZRcut@Rst+EhsDMN+;bYc=|C6|p?WdF zU~G%jj0cf_FcOR2`Q9dJT@?G8>>;Et-=d^2@AhUC@>O&{mS&;Oos7S}>i&0{0F=g6>oepd& zt|%#j6Zh1@!fw)z<#~-?AORJ6P1o|Wa>9b1f44C}q{%;8x(3<;<|`Gs1^Y z?X%L_Kv<8q+&X15HTiM5-CW)bfwx<`*^wf382)yPf*P60=*iyn+3Prn+3j={l$_-$ zk!ZBZVL;2}7bOVA_)GZM`t*pfUih|-ki;k- zMEwAjBL!~a^Ig)a7#m;bS+9cN1vrUWDtE!_Y`+FGf~Q@D%bLqv4P`^4qdvmI z!hV*(B<*q1|(hL)D}4Ff|E9I{!n zZeZy)EQlt;z^^`O|*m}I$Adn#WeHY_^f7)rKYk1+gK5!!nTvEnmVT(lfi-Jw(id;=lHUUni+pq;uvTV8G%iKWb5uj z^6Adb_Vx>AMzj)L8s4z3C|0(XJ|-@RBW+`@lawk9NuHaK?!pGO~Wqr z5Lx$l&p#hc>~sO7JUh_1y$zfb?QsJhA7?Mkrt_-&Ja1(v4Et6%tzo1TnNV?Vl$Dh1 zs}ETi8G*OPtM8XYsg0JLAxa;c-8%W;@hj;N?S_vyp|8oFv>^VopV(iHV~4fQJe&DS zhvI^Q?M&dvKIH{Bm6}D^4G(b;4nIKgFDN^7?mxlxcD{C#2#3jF^@&e;VP3>b7!$$K(?H`SV+4me+`m z{qF0xF=yIsy7KD$K4nd-UI?R_C>YVkI~c2dEL2o5`BKqdoSXuO4sLI9ExZVOl*=n) zP5DGhXt6-kYw#OHVOe6jg}(3XIMGq7 zbTn}wFvRx}#i1J2icvg7oyl!7@SV6{4Dc~@Mfe;YUbxbNS6JF_;x$a_Jos2)n1&}`V**$a`7 zkW`K)&i1RjgzlMMymHY8JJE#P&=gfh&8~S08cgb(cDouy zxyfpo5KV%Ic%#5)Un_KUsrsh?G;j$Cw(p6QvcTj$s8)fe-bgjml^ZN({A-#XgH5|b z7#3tfsw?$4Vd_XL0R_M44hc!N+Sg!dfi4Fm-gs1Z325@=7O6*gHE_M;`?$#o9|klH$*12l z>kCEg1DQR!aA4mi z4`mK?c=HR>qA*VuHaVcWEQ@CUju1LEE-@p_|7lHR0=#q>{w0;@owb;jg&D__S@E4{ z=K&IihO2+*flEcjhy?9>Cz4E)VtZyoa1J!`K6@K>MCHwT*WT|2dA3&{##cKQYJ3Ie zD)kU3dvgL|K+Ezt=eE6zvks8-K|Gr-SO|bZ!RbkqFBM~joj1shuelMbI3L^muN4lI zPdteDY~;po#ooOOM5KnUhBAa^qb5g!hfRf%`v-|qosW$fg3L_bOy|dL-0o(-c9PbQ z!7^QnIj+ddi~2lhbE`Et$Zz4Fcn6DW!Gru)bJg#-Vg6|r^^LArpd|A7`MHduqN|dv z!-h6nE={d*tbiNE`01qDn@HL2I0!6-Xatt%QEVw=XW8X4BlH5~9kc>@F4K=mUVXBb z*RE_FcV=SW_v5!>Jdo#3+Mcg%{4df4#zcM(h|I0^#BwuS!$Lr@`cig(Q&P3a&Lca7)M<_(IA1V>EGFE$ff7cV0w|v-270>C>ZEg)f{(s zAK6eg{kzewEw`vr)~=b2TdpO`_S*U}LsWF&;ZS2%bXan1z4HwkbwC)oc2HrkS1U#+ zhfOYRD^h$e2la(f`tBZ^40JbU5Murp(t)T!{{TDD0AonGDFH4^=N=nr=PAVSP8wP8 zOd=y<7ZIzPSyFVp$Y?d#eN7Md+nz2VIBG@I*A2wwH0sQ|1I*j#2?z+R0CWfMeL91P z_>pRdLJ6CVi>RJ9pvG<~Ch|Z2m70c{^ywn|dAaY{oig?}o+RFK350m@Ks)*3_Y2Cp zqnJ+FA@z~3ey=j+M;|)A&?UKrg4)R|EKvnxlfdKYU;Fw)!8N=j-A2Wakgs{<1%K+G zL1`QN^XJbYiFwR!oA0s?w{6#}iXab0>YaYNj+)sk_*hdNQoSbo(`%3hAaZe2Kj`HV zNZ#zSTrr2dh9`;XBTfYbC%^-LI;f%bEC`J|_*S#Zki_hlEI!lOI@!;}ih-$Q9_l!= zLBFpkh)^=g=&(`5hT*XyjDv@fX-j{S?HjG0pB}GBGlX#lPfs6VmM=StlfICntA{@% zX&E^A=fg&)rE!nizIb!~`@Z|cbr;ULOg4ciaq@CA{xbsu0bLph42KvshTAqd1Y zjWQYzb~*$a9$@YFHge6PjDh`Comk$!PE2e|dvdNeVQQOzGiy=sWe0zRGpLRueMC_< zR=Z|Bhfzc90zwfOWTR{{9oYuH_6wqb?_1L4tYEBE(t_XVP>nM=>t&rfUJp{<>SD;xP5-7Mpt?q2hi-0-@wlvuF_Q_w#4;0wy0tZ~#ve6-dV%IQ-3Q=(kco&-(AD_tg9$0Z8YPl}fS zG5OjO{L!3Z2%-b~f!tr?lQ#KU$IO>^W*IjN9p149hXrWMDvGG#Kndl-FYxDcn))~1 z5^v10pF<-fZ5KP~4q3#u{BUh}PcbU10mUCXJnB2&w6xq}1g`25rszA@oRUI8!y|q@ ziR>F0e+&qYaif)xlf;07dB0HMV!)>TPmFWaqY(~d0+1rJv#{`Bj`RHl2^@W2$b5o9 z{K;#Jf$qRZC#iJKjD?KED5JG=BGH570?jy_O0>2A;1@-4cvo(vh~o40&#y^6tmhb+ zJAN=#86E!7Enywr1K=qLJ$kfwDYQXQ53S%?H`UkJIlPcXaW5|~>Le`zQ`dQx?;Sr! zUh{uq(hfR47(e_%(*3K8Kj38LsNoF~xtqjON(b3zb4Fd0r}Rk`zX&}SL`baQUzL39 zFnbgbVD{;(n~d!8k`I>xp+NUSN~OR4?3md?3gFRUAAX)EExVn&6+cWZ>T2^Co`Cf5ZdJf!RWwsK4in^({owwL zAgQ@F9Q}>V=Z3%Q|T^Rx36Gpu%X6X;IAsFcI&owqT zq^@&CnE;Ra0;=9(dk&imk|e8NZQS!`I5R=`ts!H6BhyzbH|2Jw@y*T6RdaJ1B+$OK zyfjfCr)ubLYBt_g{Rs+!_K^2WBCzBy(g8kr>aXwR!S-F{IL+$N`;Vj_{RjE?auiu; z1x#2NCYXrD{?LRuNJfGuEfz|6K>=+0^V&5!(Gmm4cWHv#TSj)D1xIBcWvDvAP?Mss z2(6-uWJQ3>>H+A2uV-|3juOG>5f4fmz`_75ssHVTQMK(N2f7|Pezmb>>jH#o9lH!k6H1j9rlyA3Y5deLvZiSn(@7TW z!sKxucYcV`oXqMGR`!#mX^al-{V&aSTZul~6RV)SSRT6En%6I9D&~T!zgN3by<^Sv}j)$;jWOx)uXJ8OgCT$ytS%U@y5a< zBKSROy<0Rzx2%fB&y#;^-t+byO$+3I1aXo|Rq!O4*M^q*`i$lJN&d^i^@*6?*T?U^ z{6n47H6}}R*7SzN*Dhz@;5)6n0m`5GH$`G*u=`$=3QgjF20*}*?*@3mi+}VF3Xsfv z-qgmWUAOV#g zWMTD;$|x(pV6BvN=4M=svRyT= zoMN#E27e(|#Dr*4+4Y#xLu0_bobwy6L5=v^(U(DJ`~}Nr_gnt)@mE(Houb%aF!c*h zzP-&Pt+NOvut4{s(JDM;iY{LsvZ@9jgq7z1tF5O_meu1`|ItW$tfzFv%RC9<&~b%! z_wTsv!$P%<=TajH9|@>4c-e|T5K6r zJ=J}&Pc-!XS9q5k)9P>t8t^fZI)n6vVqz;u_iBf?x4ws16{`VxF8Rd>;&(--dp$(5 z>Sh$dt7V`7#`#a->qV8nD(&|qr|*93Dt3%GM7J?mK6eHZZ}1F7EG}i-m3`(-d)jZG zr-q>&G-(zvuiaFTW8$N-`8L)8WVe)BRKiy%3IhSGP*H4$=koTt#pF-AOPD~sz|Z=m zuLIafz4pYSve{T_!G)fnsHz}9o|n0MNf&H^I7>*zbwfCsaSI(1DG3WCDM3L&OW9r@ z2QHIt;j(-;=G|wvYm8N(s4>5OJv$#Hd+9(}gjP={OAb;y&M_@`5CAu7-W!aBv$07O z6Bnzlo22W^(j1c4DD{52ZKIAmTk?f?$7XAPjOzHo+_c89x0J-CnyrWbN{UBApd{IYIx{y;$2l4qF$)#dGaxfDT z7RoyxpV_=)de!C8cqahJ2D0bV{JEDFlY52g?%Zz4P5`MYNpi|ssvr3fwP3@Wfnuk13olrTH4J; z%jZyG#qv7ccQM0XPkNSHJ_#Lu?cEzH;WGd|r|{i&-y8__7Qm0$QlCb%dLj0!x;ppB z#sx1%t1~70g>42#u7-w&y7T&x(`l{LrO___$sqA;1ktU1FGXdjS!*eK15GGRU~c|r zZ-ov9;pb0Zy7(sEiY}Z&e$?k%|K}(dO@X_#fw1`e_-pIV@dQM?_L)z2lXPUE4Qxs- zBG#&>T1K~nQ;T($gRltlBF_&O7fX#IpX|QEMz1^FoNaK@t_l6Q2axu?%G6;{@YeA? zUMrzf#nyRG#B(0lXyTKIH)9g>{{!}u#pJqQXb&aA2{JrPF^zAS?hiX?%gmBDV7p#n}u zLr8ax0{%|blG`u~8obp$(}8i()Wii)Io>y|9L#Qm*FrZ#({hYjH)u7E=Wvuk5;y=z zW!azkK21jlgL(D#puwhH$i##$?{cuV&Y^X`$U(D0_s^vOQkUafL>cj0!VOrZFno}v z=W&%?#nWQH>&m{|ia-F*h7L`=iZ9LP2s9>}E7!@71%X>_r=5B(Td789MqPd#U!N|= z%$v1|A%broS&;{U5sE{9G_M9)x}#7({LMPfmQxSx&a!`3;~Q@7S$LFJP*KK4lMb%h zO7?oWO&brFZ5&a5|2m_P@eqSFR4E;uTV=OEJnV8H0<>3w|A`1?UUj5jZCH5ihmDK- zVLNP6WbxMLsRa*B-|;D=4;jRYygi=}K_rqe#xp4$ELP6$bR11(r~3SQW<6U(X9CgE z+IFdNYjafin+Axe9cMdsySZ36S$hvJ`eSdp`1Q+8Vr5yK^m&QreTh`BXhPO_gQXvW z_2(w50Qn;AiqIcA?%1~LBT1=jCWZ8W+GXo~qmTQ#)@e~gqp44qQ6clO1VS8q0#n$X z?j7#YS|5!9Q$>V0j-^-VX!P?f?IiaG?=Sa1gJhji8n9+Od)Djx>^82NmYqlRwQ?5D zIyB{w`of$ee1i7dn%4XTPM)`XMUXC9bBqD9NrYz5wr;nMlJon(gr25I;fZhWEB-7=T>4YLUhZ96gWZ=%q4qUe&sqf5pY`E>}|LfR=dgtz(Z_TT07SE z;`23|`+2c9Pdy)xf(s+ zZ>>ut>t15VShNZ#i}+q@fWEv-oOMo0U^o9O z^b*#3nsYJWJp*OlU0ZtOiQSp1_y4eriNxJpLy+dY93*gWVO}-CO!S#%)Wuklbq9Q9 zCjAx;ky7vL`uU)WNMmgK)%L}wT_YcsgJ|B><`J@I^qADLq8Z>M^S8IQe!DZC9Sd}w zrhf~(0k!RR@NK%y4G2)yEPoL=_S}(Gb^45=S4^($6!~ zYqc1NMSeC~+W@s!43CUmai#R!ehETMw{Nv>!(~8Ax%MB%N|*Be^fNBg(4Kq>9ZJvY`W&NUPE$Ru|;fiK#%pC^haE$n_0H6 zw7G2!(-ki%rUJCwfN{=yFC0CR0AgrVe^v?dI=eFElC?5}K-fH3CDJcnt+$lb`?CxH zNIihcL^*8EYi4@Wv7aDT=-=*UilG-hZ7L>-59(^VAxTa_Vd2JD+v$&4t;crRn`1Cv zqQ~K+9oaK`2OcVqF&|OJ=WHWl3)iO8{>Pi`U0m3P^~--J8tcFU9PNZPK*5=>oR7+5 zV?FfUKjT#}#kw8#du49krn%*>j_Wn9hjV_ub$*S# znKO2g4YVo96F|ibu(5%X z_~Cdf2Yk!-0%Y5R!=onk?V*Z^o-~Y!$*$R58GM-G2G^h^W>5^hsCoF7ClhEWdTw z^Q;HqH5hl`ET2&M6hiG!a5nOs%E`gZeEh3b>FqwTho5~u^17V{~L6)YCgR-gtR8xD=@hm)Y{??5j10z3w#!u2sPftdQcmFQq^yKJp=H&DX z1=&a4<3p$^_Ab1}K&7wgs~NDc5DN8MF`dVBC$jFPeaWtN@IdCQr}uRHsna(135Y42 zt^&$V8nUrU#_a45x>Xq$zpl$7n)neyCm0`oDhcX`a#wO>4LrQ$}1AtS=9EXyYE}ms2J4{g}9g6c5;u z;XH5QuH?uW-)M(a8nk*syH5?{x1ffgYU2v%1OPZc^K3VoOk|FV76zZq=Ok;4*5i;F zAXF2@?iL+2&avv6o0&~1AC8!}CM#?RE1MtWM$>u6G5(?237))~_m~g4_GH2O#tu3> z-lpS)-=)vpWyR`)K4|b!MdI6~YS+}uL&L-0gin&szjpYUh>JsmUw;vKvRnLoU+}qH zTI?*Xv4n9*&+{HjS@3)w)T!jOr6z~bnR5a9;K{^i`oUo?woy&t$JKRMPO+F$r$id@nDTC{C=4otogQXVCH21m)S^ zzarnSJm0Xg4t^o?4VJ9x3h(U|2h%6Mpt^i1x;IEjFGJg%|9jc$KV7Ws|7m*mas3bQP9GwEybZ310ryE0VR2J+t!#sXyj54U(99r4O10@7S?U4YpMGXc}- z>2^2YbnqWOmm|4uqb&i;N*hTx@7n1aS#$F#jaJAm=8f{x&5gD~mLSsBKx{<=R@OIm z`y*J;Q$;@bn#fwcq90Vv;7z_#l0dGcf&)dI$EUS#Vgqc)4Md->Lcy^w4pAWb+Mn{22 zf_2sJ-tI-U(egZU;VWWdlyD*f0|Cg)4^IEg4Vci+2xuRGc50!`oeXqgD!>5;B9^~= zvw8J%wVG84$Mz4LUPO?cUx?$O>E3>*~PFiPJJ)`EP`myb|tsMJdc_IDK z_vHVR*V$eVp~#uPLVTI0LoOmBVzo-obk8Bk_od9FS5;ry|424A_uZGx7=e@KT$_(g zynR=2Z#AZhFeXZN0fdI}47iB3OR%Rsxelj0gwTYBM8JesBd>NI(CX)bUY0{KGkN1e0bFLjGEok3-cw7ojtP_h^LgE%ozg^ ze6M8=H^F4)UxDaF(@3m|D53cbbs8y!NN8MbV(Vw@Nl{TK%U*{SoGi!g!&JJD_f{G+ z+(<>zqF@3M-@2}@ZdQ9;N%MG$k)P+*Aeq0QLdxM6cjb0^mHlQi`$*w`h#22%4^_-7 zjO8WlQg!MqHq&}O6aMl6!j@c{6mn{r!%22Ziu)i?ROy{8 zw_w?NGGlJk@wcz5lI%5G8&uJJczKaiFa91$@wyZE*5-VFsDz^^bvj?zavuKpG5C$G zW<(g9*$_Gk0gsDRm0`zDz4fO%TndS3wX;F!5U_#X52$x|qd=}gK~Fz?Z3qNl2NI#)AF(j(n>RwGknzDI2NI0S0tLH^ASmRh zeSrLC^Cn6xq=b_gh2RGcdj=04jaye zwp+r>iveWn6GFr4wz4+!*=-e}MmM&3`x!!2w%G^ADpNAS!{#O}qL5v+V&%LMY&bS} zSj&PIjZ1b#-gJ?98G;ebYZO~QViQ0?sW#zw9^c`8{qGDqR9LlRbodLY=bQ3BVA~5t zHx$>`*UyKGs;zZi_PJm_gZKVM@E%dy_|i5B(YkbP(B%kDR8%|n0oBfKdv_N|)lR+C z5r$T?7a!NJgDiuanDF$oEnyPm&w73Ae@3IbF^ z8LMtus_xYNEkmcY36?t%$Y+V`9oz`-eiQ~sIzr`K`mTYeT}e*N_mId*gfYPvvK$xZ zAIJ9JY^pR<^fdcK(C_#!TxWC{=dKc~se?g@jFNmO`5UseZd4G6g9`v`{E&Yq^h*GY)t?(Cq z7SNm>2&$Vkyt>} z;oB1g_Z(4Pi)fXR(2Zg1D|r3`i*cr_rJG_wBPt>~x`IbIcc#{S2;R1!DHh5UEL<0XpdoUBIQ8ekbWmRv?zX*@HBjfy1&3XHxc?%RJr>*@-nKQZf z0i)q9SkIgqv6McUCo3Ethb5I#*4E#PU(NloMj>A4QvGEF3RP;RObxhqqCqCrSw_7T zB&=eLoN`V3Zp*Jf2L{?rt0VBCMxX=s*mjc$OO&bF@#*mSm4BBRH9ANvzk`cxJ&XLd zxLj{Ny>1-8x&Cwh(4krQ=+OOiaqE+L`;&0KlMW#aJc>#>F>Ep>Ecq+w1SFKe)tYep z8DZ4kCt-M`I5PxvexAs_9L{OcMh%)U6&j}M>cy&Zh{fOSVX7Cd-phLRfHXozA52d} z-BOz2K^MASM*ehV@mfnuTmq0jS~tA4yh)XAS4kskTdkR&;n9M*5H%3_3Lg>@IXZfR z4U6dl@#7qcXzIR0`s!ykGva3EQE%ilAwMc5^LE#-;E){IodwvecQEYw_CccGaU*WEGG}y zGQzY{*?~tW#2B5*cs!aWfSrWHIDp&)3Ox?K54I2bzMdO*RFAKT#Z>j>eZy)bRD#!E z1*eoH*OJ=f?(ueEdCXyD$DF5~xjBwS*CogMwnEc`83Z8Jz}1``DchM%eHr`_N*+X! zh8u81f-Ja`U~TiER)x2J{82=!6U zfnP`1Fzfg*RDfvEDpouH;jGl@myZ+f3y|&S_h)u5(HR#6^NW2s6gBhMB=dt~O^zPd zAYlIhOU+br#}zsZJ3aOQ8+I;v%R(bzrd21`yay*HQl?i zN``GVYHpy}32!rad*XDsavuSlNEFZ;M6>!Y0n6n|yL>BqTf>n${UzLR?yZa5@YnQoHxG5t|OVHyl! zx&hXbf4gLrH^v7qj3B9f8B9&X z_hlS{;x|?^W+r=Z*#8?$)nQ#{(ZS_u?k6S_{qAN!DtD_e#V{iNeGIyIl(EGN#H{sv zS~QM;O2}5IR;<)%uRoI9ai2P$Nlw`>Mjoo}30oK~7BCDC4ZB-FgBX_xvM>waaCK`K zUyc4Wz*zk?7bXSP8MrsS90I(gcch(9RN{Qy(D2lVOw~Zh3eZs_YXl=S2LIE=y-cPtbs*(!A!ijSVZ?h2 zr^@ZLk~%yM2?HTrQG-uh6_#t|*%d>3nL6C=C+%=Rtt$^1^0c&;_rG>Be_PE(ZrmML zXP`c8}DZpsXI&20LN;D68L+iwAtIIvrG1mi+s4Uh<8qE}(?^vT~ulkfK zO5r|=2B?_3XAouIaK>F?Z3UwXCuAgIV$rSsGd~ObtCq4K86Xws>Qs*Pqx4n1kK@6+ zFE7#-VY}b;q}520j$x9m9};8QV)~*Pp@xFQ%x?q&^%($O#qI+1^BZi}1Vk%F&vc%yYa2Q}ubbA-AnW$%Qj?vJEMdHv61v1^jYCS?q41CPS(XZD;(~w&aI*aE~0^v zx`oCn_b&R_OBnM$Pnf~#`#KFR%VRrjZg{*uy=NNaOX*;?ajWC&*=X5ex)fWWr_ekI z-Xs_^nnXv0avn}7mZ&CtVDD+-cRWp^3+cQ@FfT*kE~HqzSUFiKwcvqS#PQsugUl$02NsI81-x#jmDTTRze4{K^#J#T*X{7^s2CP59;O-FXj96iX6`Oyqh~dJZ-kBh=2z3y7 z4f=(SqaD>($U=2HZ<0-AT>xfk>!p1a?vVa%6VLpN1&Q8*iaOSFzZ@AGGu#mIH6KE% zBBHk;pV+woO&TEHUkB%GwFraAV7yO;UIc(2e%bso)G1}Umw4D0d}uL^^=b~67u>25 z!xDla-+$$P&Ve?|u74%R5_O0ew`oIO!s!coW6)(28GLB~w1?1-P0F^!Z0dY{&C*i^ z*x}WQlgYt?x~gteqX(E!u{bwQD+)Mme00(YQUSN4<@TWE5I23$s<#@5COiQjVexMGwt5W&=I@{fGWIxc0QIp72p`cw|Ql3THA&jCS6o(uJ! zFj6t3h0X9WHk(zT$Boi6E@-qW?uLg-3c(>hDE|7}IQ-XU96k;n59nq++;6?3PlS0Q zW6+lBG>o2OYsFXU2sxat_I~FH*&lge7%whT-wVrIwB2Xu?f@&G$I~sIme;%*b&=Dn zL9Q5A4s~_)AC{IDzDH?Y+xHO>%=Dq|R|1QsdAIyjVM^j1vVsqbmCTj$oXS4_;zik0+Dz{xr( z`i3)oKDITNT6%@tPN%{(Wa&{&+-`ZVkzLw3KYAg@y zK+XT?_*? zSB;)YjEggd%tl^>l6owlmA0IU&sq`vwMY383{(m(PrKHCs??_xaXE#8AR~&B-Rz3B zoAR2Pu2`!r>odKQkojQaee8gNwq`!U#To|VrxgT(reBq0-arhZmsCOHXd!)zU{ zS>ev&XaYui1?UId$8Tvxopi06dzu!T^hsZt@cmOi1qN$Ji;{y+(KC8@!pXq~1h&>8 zNt90JhL7m|4ab6KdwRy<5t0#HC+XBKoxGo%R01QwGT+BhheJm{SZVE6KBDz~RU655 z*?0O^0%%??7!@ET=qu#yH|H>LgEUtn76Q z3e$|w^%K@2pRuCf{JCsW4La}dkZZK(iiNhah|{;gJ@J8`8jBO9+h|`c!`%EC?&Jc1qA3LFQzu#t#;u?%5L=6QutigqP#qx4UnmW~s@D`sUwj^$cmEsl#R*S62VZ;x-OV9Ze%=jI4&bl%zQYWo}9dV^>NG9&cQFm@P>S@ zd6Q3B65WelrSZ}@NQB}(M6#E%?>ajA!7}s?8{6v~UKvogWwz=~1^+lu^*z^jlr&NW zH+#n}x4pXW4K&Clfz|TnUH7@!7US2gOKc-{n0$B!Fv#>eX-pr-<^U@OR3Rg8 z+&oY#|4go?e?w`279_pmF3HEmzWc||f4KO$Vs5iur^SDBt52^gsOxM>Z=z__!|jDE z(-VyAIBmqWDc_{PgziR7UvtvOcRV#VrW{w%XFsRHh1Iwv?q0N{r1R{0DQAB4uL(#s z$y*scReuS$qW-R)DL9#9ctkNlSjsBsqlxpDtfxX6jR?XV>j|k8jocha>W~t&KC7M?v88q{B zY?Ei$Hc|zN31F3)6m^$FB!6!^;_m?Y`%4F%gh(!e?rMXme4O1E>Wt)~`te3;dPlCq zJbAL8r$pIQCVp)&WagHII;_0Pc^#Ombq|)5fL`W?&{@E?E&qIdNom2t$oSpQmY(d@ zt5=^tv?xbgf~rtoH0$lK5KXb~yUz4DcOi8QLVE`s!mieNXW>WXRDCQA1X$?N>Hs;G z*oJGZxG)pV3CiwYXX-@q)KZ!+V+D=;!G5Pw3Ih!xxP_C5r8witJr3A-NJe5$Af%&q zlnhyc-gjQPIxP97^Getri!Jm$&<;(J}N|lo`4dEcIjK_D810z)C@PAJ2R`z7F!&Ad_%FM z73~W%TpG!yG1>%&hwP>#g_1c+Vi_E|=afWHwM9!6IxIDUmmOy*->YftBN6+}TEq3N zVtUgD-%e%tiRH^#bH}-@{_mgItF#{WNU%gqfcU92P)03tHHK{dys?IkxH?~_Ju@Rn z&haZcv*y`Zs>fql*h6MoN}RsRo`LIk~|Spycw*es>v15V9#M6r zR>4vo676tAr@kx%;6mGgPDI0^5*sCI!fu7Ip2N`F68u z@l0R9~Pjo`yd;Kyq%r78)-$$Ee?x8 z`36jw8(VKo_zPFln8yy6vorSi#c&VPN$6?$r~C(rKb*aGoc>QOK1Z+S_Aah$a;S3Lw* zk+HeuItmx>kb>Za5L~B-W|DV1DQ>HnF-Is^ zn_z8%@v`%%)Pzb<#*JQ6?U9HS{heLhSPHN9G5!)!?g>*f@;dSd80tMQXJcnRTak|> zmuCC=&lUaWL-f6uhv4?s1NS^QJ*dFR^q;TWA&TH5VEew^u{f*0$C1i(bUjK%O?_)9 z!Mnl^_4}=|U1Tqjf4tQe^1?T)TtkR4F`SA}@Pmx_(LNCo9g@Sn*#lWtL41VN1~g0Vpv`HLU%mT@lyNId`ws#P2|G6p$DRm%2ZFj)2{Dxi@3 zPG2t~Amwc)(i##vcZ}mW&Q;NdGO(9lHstwBjMR?DL}n(u2GKe~5nCX_oq~?mXH+7D}7?1Xmk~@>3=`H$VfN-%ued;)t%{L zxpAMyBcyq`10H7ddO-XcL|_Q6iH0wJ%uHP~&JUO{GFy;dooo*}97R!kx~G$t3k!sr z6-)Vk%98*V@BNdL6Uxa%?)Z43zTCf8Maxtto4?Fol=U!VO{0Y>6-o*<2B zj=GQlt8|bWAO}x8JaN`nO9%}b-N^q8Ree*OBUm8CZ_{~DeE)r_St;nGT9|mkA*g=s zvN`FDX^mvyR`R^J;&m$dySLI~Iwer9aY|swvuZ=66yTpiUjbl^%h?-CQ&8c&t*OfN zpWXk*%m*QNm!t9nV40Xo0XGeaT33s{fQI|sBj^vE0vNiKwGSTYH#~VW9IlgfGWT_6 znq2VcL{m=5wu`fV`74chXix*j#F<Gy_7>vz9D$u~E!yt-aziv*RN-?i!muG^F6w6G&NbRy7ub$yZPIk&rAKNG7+@+4t|_g+OvX?)mD2oo#TJOufy&-o2x7Q^jS^< zFxB%PEb?GsasR}gwUxlZB-f>YQC;-bl*)sl4E)vdu~%iYzh149as(Lc#GF?J7@>v2 zHi<)G096?zC2gJ;B?||E!$S>N>pJd8W<2SmJ#e@~0NGHF+)NHk&bWSl3xYdQ`R2<|-lo_s%yPu&tV# zKUf6jYCu+9wT)Q%mhe_jB^m@H^?i_s|39yqbq%_Vi|BMY{|nrC3H6Up?Kx=-m_ea)K7sK!7$0+kQkwg0)g9f@|wc(|#O1njX|sjXjK?yT1O_OqA? zQ!id(Ic<{S73VlXv+$sLqCTx|it#ZdSno1FZyd<_9j!^#_w|Ilx41js`^&<~Il(=2 z^(FdqF5yEOrXed%s>8QZYJ3*`G~hYl$DcACc{fIK@@I6!lB{Qwlg2cWR_Y1@$j{=* zsf#E*tVh^195rjnh7{&ybLUx%R8K0r_)AGWMMtKt>AeiyWUv&itcS_I;o;?cZ66X; zAHtBiVIB6q|0a?DWag|g$x#hPKzT2nP3Z~EW{U)qd`Pj0N0d_L$+x^4uY0&jl{1Q6 zx$ZfAxLqG~n%Lj9!efTOI1Sww?Ct$emXN|2C_*(T&kTm0dmwYZTM}OhMplb>wbBDF zXs-7-5?^_Ec+g{E0^E357($DTxnNJ3n30!D z3QKv4du1;a0vhMZcy=6GU82e#yx@PZwlu$3on5T7uRp4Rdnf&1e= z`b{GO56H6>=gpn^jYNP-bNcr>eHLIakw!eZw(W|DPak#nKZwR4IQVDDrwC)fPJnKnkM?fT75^<^Wf1pr&y2=Hm$opEl+@=yEn(gRa+1M09GGh2m)W@Jy zGRgcW-`M#1J*p}%VA1h^!ftBcdrj{s5rq#}hF->A^+7Q-*lS1NXEIQ1N zn3xKh(#&)cU)b4^pA?4OZnHt`bo@7KgH=O@#@f-Jm?2O-=(8+5>T&-^z#Vg)bR0AD zV0|bZgNmEoiv`P0F^Vz19=emnW`i&KY5$Y#M`sMke2(??F-^}d*#I}7s2gN~r{jk}cF#NR)G zDrFEN%cDU%wTU8jgLd}az$=kN2XRkC(#0o1ltBD0tr4G+Ex6xAJ zEheTwST=i^#5ZmDp?Jy)9;+&5e$qyej z*Y{T3ylHVNnP6-QWmSAm1gLeTFX{Reb+WiqCA8XDSy+belhJP=)x7U`dF$xzo&!A7 zW`b-;vY3Zp-`Bqd4gd}JhZ@A=NaNd#q~>E^}Vn&+V;Z^pw%jE8Q z)0yEnb(Rfs`Mf}m8~CFSym9hf8f@vbO;sG!9M~k1Jt-<>Ac!Yc!ulGyltRfEWCr3b z$uXrm1SP(L;*OZPC_OuN!ACH@xf<$#%pVSla&t7YK^L3DV~WGH*>8TIuBz_kL)NYXUHPyw?ia30LS9*W zE28@OhS=al53}{@XmZ!AYklQ*)UIk2`TO`GA#?^fY^CL>HMbq>73A;PKc0&fne8Ei zCQA8?WJYG*!6-`|A0Iu0MZ)a`!Lp?|1|6p)NE=>lyrW|JnnI-u1@z_@a(%br#BDSI zy_vXis8+j9MLtD0v3z#8m1HQ{rlrc-@I(Iw^lZOZ#rc1nv4{R04+ zI432sD915e@!tJhe&g&l100P5#>s)_zI z%n^SZY%iVj`@5w4?wlI{pUdcW`PgYau9uT8=oJYxH7nIIsB99LG|vSBDKoj;bVUKn zsxR==Lw9+!Abi0CndX`&NQe6K_!;9|n!3~Nf6dX;dK!vc!v`;JBVv^e;u$n2n?(>7 zB`838>kVIuyY9;Q;JQ?IG}~%_6_%m+S>1$g%gM*5s$7SRj10}%aT~)dezFEz&65u( zIV~i)TTBB!ER}$e2c`k}&FrT%$@rsW;e-t6sgGuABRaTjGJ_?PhFzQDEf$Ub)A{d} zYulmglOVVj+b{678ceu*I5P8otQ--mxXG}xViv?EYDxvkMa~EW}O z-Ye+5gg#)|9MNfrf7jG+<8Dh0r_yqZ#DWY7rVPCX?oTIQe#zK_w{=jkUN))HihRhC zeaD$#h;a*LD4Eru5SP+aCOFCqa2wHM$n-fT;h>tqBwz>HV98BwHJ6{_EP&Z6vF-D0 zfJ9?_l@FDY?0990@w^Oo1~ zYyw~p&LjQ9Upr^&&%liQP-bJ}<|9-1|Bu`lbpC+{kzHHHK7&RqlNMx!e>do_(F6ik zqyA;O#>Nu|YlU&zZ@*fF?5^b(VBvN`WN@o~yA1!)FQC@XtJN8)xlIp1J>L9%*sQdw zml^i$@Oh+A(3yW9gyZGsgWrW)=W28F(nzym8|YD;_2r<&Z+$CL!ECSd#t{V@bli`X zprEFPIs2<%xIy#mY%__Pwg!5|TVnZ#9!mCzX)40KaQ;m3eNLB<1SEx7VGu1koixrr zI?tx0tm6XMlS}e93(q`zu>^L#b^4z?^)K`B_4OY9LH)6z>sWqfmlC!3h}(hSp#uNp zS==Y@I>g$7YenaQpZH;M(o>xf2xgqt%$$Qjq`D+W4{uY1&EKQjEZvH8EKE10j7mRd zLzdS})gGQClK9&&%}1+RWquO@iluM8h7}bWW0KioAQ*O$<;bz5%o(>~GCl5IxPXz?WenkK1k+ns)6Ru4IpPC@VJ~bU; zqV{jg`L#+4Ldo^cq6BK|Bi@8h-P{-3eRrH0^jr0}K_V__+2l!vvjT1hi$YWJ5@zPf zQ&mn@P7MJ>jgb)Y0nRs!xMq5oy8bGQ^x?u%ekq+-6d%z8zOud$bwpZ4i3Ex|Nc)q* z$W{1HxkLnIudxfcCIa5+mRq-W5m$!6p{s(<{Y{k~z(St^wGMt>hKtFD*DTTNvQdvw zFe^^EP5D+xHZyui>6oN4{6?Iku_zhyYjdkfOdoBuxe6`~9&&pQ0bFEKw zWxls(>wU9mw70a*0dQ0NoM8|2gvrP=L(Rt-zmf_KrCf5q{Mebcnl$_$Ru*1P+#K1W zG^I3qRq`O8Cnjrmhd68j-8RIc74G-;md41eEK6mryc)tgm+fFhCvI<=d~0G?behYm zZT#>kzPmJ~bH6BCQ2n;oUm|C>C$M&A%)`nq(4#G;vzHB+(-6%eVt+aU#emxsBgzVk zVn>6%Iw$sU@vt4}3;vl5n*8f*cB3RfT>D8MJLfNA-fuZXxJB%_>FLOgJDmd8P1nw3bcx1UP@}2@HJC%mfGYUvV^p@T_;c7mg;PJ@NmCG#33naRk^j!RLx|6Zd8Kbp`AEG$h!AxrOmT zYw84F6Pbm4t6p2E-0U}Y)^|cSOLRDvtrHNOaQ|3>@Kija(7%{FUOx`Nh3auX#S0ix ziq55K`0;(B>2mm(WBM6Yn8ibJaY)RB%d0%Ju=h9>|2xeJWh-LDa$|KQ@rwOcMn-BtAVR(i9B?w?rMDJdU<)9T6U1ezk z-jFfs>!U5d^uP2#&gPJ}n_{h02}9o3gk}!83zhyClT9`U$3-N0JA3Lm^qps6I@ETm zYRDjYXmgdUxV)L(+4`#CDnbbHoH4OlD(Id-5x!QONyL8>ns~oi&qr>4@2^J;6zMYV z4wcI?7m&?#lBADeDWT7TKJoabf(Sq91suxiw%yAZ8%yuDsxZt8sLH1nee#zr^jx(=m z%RI`fGSgFlEHTH)15((7-^mAWiPk)WLm_ZQbMgwqC^=5aEA6$($SUG&zugbjdBT%f&!<6Q%H zH=EXy+~raUgKOqLtdUgc_lq|!Me^TOL!hkP2lsIfB%&=rS<@XBAHol3oR`P1ByYzm zfOF8;6}|181f-FK?KMN?35QFk^?J%uHEbQ@K5RXd1*7dpFp7TdBISf*Q4`0=95TkJ z*{c-x^8MQ+xA|-mWNW$~oxx3=!D3$=$@i8o@J_~+7d$=^=~h;YktmW*-ra4h08(RJ z&fu_!a`&eoY20ip&7;Pr#0N**q%EE$vHS5Rrr%Id3D(L$(y(h6ndRe}@)!FmL0tL* zRF{h)9Qwpv3v388v<;+1ME-#>A29!#-(zocd{2xo&tj((gMkxou3NHLH!ftsS=Zvw zZF0=H;TVhA_$8_@bz_t8XIe^GN99G8`tQxn0iilC`fiTgk1dw>(Tzk+6;x**@WL$p zQJ@=Io%eHxSx1DhthDCrfpm^5Ja3haq|<#f{IXm<%dj4_J?&WHw){wa+M=mloIHlN ztJx)x3A(Ib!*TWs#~{7RLth zSAATi59wgv`5q({ru)W61?xhx){GWrRMS8mnU^n`$K=wx=C798(tmfFFzAvK8 zhOJ1?+GX=Ao^F=jD=HlEE-EMTH1-nPHfQiBkN?|f*s+>eW=t$5X;zzR6r?0~w_y|k z5fZ6X_`QGz%yI3+e~kj+mR=C_wj#-SHU0H#^yyac@#!0d-`Dda?LOVN`?&Jc(K@Ll z53t^sUYW3e*{&}uba^bY89i<5NmcEPpbgi&FNuAGD)PFbW}@geffM7v#0~^t+lN+~ zRnoUyE14Pqw9y2PNgc~(zSEoBjuoK~V}@!V6bi?5&*A61GP4}6}Ppa2}EMMZ(pSS5#2i*)da_r30C@K3p+&Zw6I5gU;Eerkae@ka< z@<*zS4yt+s)l>K!d`?Mf{a-pu_kO14)(KF%^aGCGOL71yG+~sCkr`smRV8nej$*cT zxB{*5ND?i^*}#~gB6db7m3vU!*sqE^Y?ml z54}mLC`NkNkS-#iD~3$^^ZVB}*qbkf|LdDD>%X&B=S~IRj)DCD^7pkU%y-K1#46xw z#FJM(HZ_ifVxD0mzn!i($$;1Qjq_sdqCDf2?ACOItnm=|AFwt{ZY_hiF*{@k{Ez^@ zfPiOR(KAE6LOoqw!KWI|xGa1Q;=KWI}Wu0j*|X@)o?TT7{nJ?dH$ zbJeTrO^X!6 ze*pUgcp=V|mF1P4$JtYAVob0VVH_wZtFGqi>+kPx;CZ5#```cR)&0S~e|O+J)Ry(B z#yvjvseD=E_;hrHKS4MA>b=67hd4AMA|geeo4q#y5XoOBZ3=E%{lV&hj(=P5^y%Xb z0ppO{8X*RYZ(+%!qO4`Rs^GA4mvR5G#=`V9pDsRjPErznDCpL55{ZIv#L$t_=3=x$ mA0V|)``=#uC)qLnml?uml0Z=v_!9*IU+OB_j~X9ZMg0%bqvyc@ literal 0 HcmV?d00001 diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/__init__.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py new file mode 100644 index 00000000000..c249bf1fc5e --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py @@ -0,0 +1,221 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd OpenAPIetstore-python +$ nosetests -v +""" + +import os +import time +import atexit +import weakref +import unittest +from dateutil.parser import parse + +import petstore_api +import petstore_api.configuration + +HOST = 'http://petstore.swagger.io/v2' + + +class ApiClientTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + + def test_configuration(self): + config = petstore_api.Configuration() + config.host = 'http://localhost/' + + config.api_key['api_key'] = '123456' + config.api_key_prefix['api_key'] = 'PREFIX' + config.username = 'test_username' + config.password = 'test_password' + + header_params = {'test1': 'value1'} + query_params = {'test2': 'value2'} + auth_settings = ['api_key', 'unknown'] + + client = petstore_api.ApiClient(config) + + # test prefix + self.assertEqual('PREFIX', client.configuration.api_key_prefix['api_key']) + + # update parameters based on auth setting + client.update_params_for_auth(header_params, query_params, auth_settings, resource_path=None, method=None, body=None) + + # test api key auth + self.assertEqual(header_params['test1'], 'value1') + self.assertEqual(header_params['api_key'], 'PREFIX 123456') + self.assertEqual(query_params['test2'], 'value2') + + # test basic auth + self.assertEqual('test_username', client.configuration.username) + self.assertEqual('test_password', client.configuration.password) + + # test api key without prefix + config.api_key['api_key'] = '123456' + config.api_key_prefix['api_key'] = None + # update parameters based on auth setting + client.update_params_for_auth(header_params, query_params, auth_settings, resource_path=None, method=None, body=None) + self.assertEqual(header_params['api_key'], '123456') + + # test api key with empty prefix + config.api_key['api_key'] = '123456' + config.api_key_prefix['api_key'] = '' + # update parameters based on auth setting + client.update_params_for_auth(header_params, query_params, auth_settings, resource_path=None, method=None, body=None) + self.assertEqual(header_params['api_key'], '123456') + + # test api key with prefix specified in the api_key, useful when the prefix + # must include '=' sign followed by the API key secret without space. + config.api_key['api_key'] = 'PREFIX=123456' + config.api_key_prefix['api_key'] = None + # update parameters based on auth setting + client.update_params_for_auth(header_params, query_params, auth_settings, resource_path=None, method=None, body=None) + self.assertEqual(header_params['api_key'], 'PREFIX=123456') + + + def test_select_header_accept(self): + accepts = ['APPLICATION/JSON', 'APPLICATION/XML'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json') + + accepts = ['application/json', 'application/xml'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json') + + accepts = ['application/xml', 'application/json'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json') + + accepts = ['text/plain', 'application/xml'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'text/plain, application/xml') + + accepts = [] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, None) + + def test_select_header_content_type(self): + content_types = ['APPLICATION/JSON', 'APPLICATION/XML'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + content_types = ['application/json', 'application/xml'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + content_types = ['application/xml', 'application/json'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + content_types = ['text/plain', 'application/xml'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'text/plain') + + content_types = [] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + def test_sanitize_for_serialization(self): + # None + data = None + result = self.api_client.sanitize_for_serialization(None) + self.assertEqual(result, data) + + # str + data = "test string" + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # int + data = 1 + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # bool + data = True + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # date + data = parse("1997-07-16").date() # date + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16") + + # datetime + data = parse("1997-07-16T19:20:30.45+01:00") # datetime + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16T19:20:30.450000+01:00") + + # list + data = [1] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # dict + data = {"test key": "test value"} + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # model + pet_dict = {"id": 1, "name": "monkey", + "category": {"id": 1, "name": "test category"}, + "tags": [{"id": 1, "fullName": "test tag1"}, + {"id": 2, "fullName": "test tag2"}], + "status": "available", + "photoUrls": ["http://foo.bar.com/3", + "http://foo.bar.com/4"]} + from petstore_api.model.pet import Pet + from petstore_api.model.category import Category + from petstore_api.model.tag import Tag + from petstore_api.model.string_boolean_map import StringBooleanMap + pet = Pet(name=pet_dict["name"], photo_urls=pet_dict["photoUrls"]) + pet.id = pet_dict["id"] + cate = Category() + cate.id = pet_dict["category"]["id"] + cate.name = pet_dict["category"]["name"] + pet.category = cate + tag1 = Tag() + tag1.id = pet_dict["tags"][0]["id"] + tag1.full_name = pet_dict["tags"][0]["fullName"] + tag2 = Tag() + tag2.id = pet_dict["tags"][1]["id"] + tag2.full_name = pet_dict["tags"][1]["fullName"] + pet.tags = [tag1, tag2] + pet.status = pet_dict["status"] + + data = pet + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, pet_dict) + + # list of models + list_of_pet_dict = [pet_dict] + data = [pet] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, list_of_pet_dict) + + # model with additional proerties + model_dict = {'some_key': True} + model = StringBooleanMap(**model_dict) + result = self.api_client.sanitize_for_serialization(model) + self.assertEqual(result, model_dict) + + def test_context_manager_closes_threadpool(self): + with petstore_api.ApiClient() as client: + self.assertIsNotNone(client.pool) + pool_ref = weakref.ref(client._pool) + self.assertIsNotNone(pool_ref()) + self.assertIsNone(pool_ref()) + + def test_atexit_closes_threadpool(self): + client = petstore_api.ApiClient() + self.assertIsNotNone(client.pool) + self.assertIsNotNone(client._pool) + atexit._run_exitfuncs() + self.assertIsNone(client._pool) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_exception.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_exception.py new file mode 100644 index 00000000000..0d0771b5785 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_exception.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd petstore_api-python +$ nosetests -v +""" + +import os +import six +import sys +import unittest + +import petstore_api + +from .util import id_gen + +class ApiExceptionTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + from petstore_api.api.pet_api import PetApi + self.pet_api = PetApi(self.api_client) + self.setUpModels() + + def setUpModels(self): + from petstore_api.model import category, tag, pet + self.category = category.Category() + self.category.id = id_gen() + self.category.name = "dog" + self.tag = tag.Tag() + self.tag.id = id_gen() + self.tag.full_name = "blank" + self.pet = pet.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet.id = id_gen() + self.pet.status = "sold" + self.pet.category = self.category + self.pet.tags = [self.tag] + + def test_404_error(self): + self.pet_api.add_pet(self.pet) + self.pet_api.delete_pet(pet_id=self.pet.id) + + with self.checkRaiseRegex(petstore_api.ApiException, "Pet not found"): + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + + try: + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + except petstore_api.ApiException as e: + self.assertEqual(e.status, 404) + self.assertEqual(e.reason, "Not Found") + self.checkRegex(e.body, "Pet not found") + + def test_500_error(self): + self.pet_api.add_pet(self.pet) + + with self.checkRaiseRegex(petstore_api.ApiException, "Internal Server Error"): + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata="special" + ) + + try: + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata="special" + ) + except petstore_api.ApiException as e: + self.assertEqual(e.status, 500) + self.assertEqual(e.reason, "Internal Server Error") + self.checkRegex(e.body, "Error 500 Internal Server Error") + + def checkRaiseRegex(self, expected_exception, expected_regex): + if sys.version_info < (3, 0): + return self.assertRaisesRegexp(expected_exception, expected_regex) + + return self.assertRaisesRegex(expected_exception, expected_regex) + + def checkRegex(self, text, expected_regex): + if sys.version_info < (3, 0): + return self.assertRegexpMatches(text, expected_regex) + + return self.assertRegex(text, expected_regex) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_deserialization.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_deserialization.py new file mode 100644 index 00000000000..92903bb232d --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_deserialization.py @@ -0,0 +1,442 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd OpenAPIPetstore-python +$ nosetests -v +""" +from collections import namedtuple +import json +import os +import time +import unittest +import datetime + +import six + +import petstore_api + +from petstore_api.exceptions import ( + ApiTypeError, + ApiKeyError, + ApiValueError, +) +from petstore_api.model import ( + enum_test, + pet, + animal, + dog, + parent_pet, + child_lizard, + category, + string_enum, + number_with_validations, + string_boolean_map, +) +from petstore_api.model_utils import ( + file_type, + model_to_dict, +) + +from petstore_api.rest import RESTResponse + +MockResponse = namedtuple('MockResponse', 'data') + +class DeserializationTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.deserialize = self.api_client.deserialize + + def test_enum_test(self): + """ deserialize dict(str, Enum_Test) """ + data = { + 'enum_test': { + "enum_string": "UPPER", + "enum_string_required": "lower", + "enum_integer": 1, + "enum_number": 1.1, + "stringEnum": "placed" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, + ({str: (enum_test.EnumTest,)},), True) + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue( + isinstance(deserialized['enum_test'], enum_test.EnumTest)) + value = ( + string_enum.StringEnum.allowed_values[('value',)]["PLACED"]) + string_enum_val = string_enum.StringEnum(value) + sample_instance = enum_test.EnumTest( + enum_string="UPPER", + enum_string_required="lower", + enum_integer=1, + enum_number=1.1, + string_enum=string_enum_val + ) + self.assertEqual(deserialized['enum_test'], sample_instance) + + def test_deserialize_dict_str_pet(self): + """ deserialize dict(str, Pet) """ + data = { + 'pet': { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "fullName": "string" + } + ], + "status": "available" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, + ({str: (pet.Pet,)},), True) + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['pet'], pet.Pet)) + + def test_deserialize_dict_str_dog(self): + """ deserialize dict(str, Dog), use discriminator + This will fail because additional_properties_type is None in Animal and it must be defined as any type + to allow in the property breed which is not defined in Animal, it is defined in Dog + """ + with self.assertRaises(petstore_api.exceptions.ApiValueError): + data = { + 'dog': { + "className": "Dog", + "color": "white", + "breed": "Jack Russel Terrier" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, + ({str: (animal.Animal,)},), True) + + def test_deserialize_lizard(self): + """ deserialize ChildLizard, use discriminator + because additional_properties_type is None in ChildLizardAllOf + we are unable to use the discriminator + For this to work correctly, additional_properties_type must allow in any type + Then in ChildLizardAllOf defines the property pet_type and allows in lovesRocks as an additionalProperty + """ + with self.assertRaises(petstore_api.exceptions.ApiValueError): + data = { + "pet_type": "ChildLizard", + "lovesRocks": True + } + response = MockResponse(data=json.dumps(data)) + + lizard = self.deserialize(response, + (parent_pet.ParentPet,), True) + + def test_deserialize_dict_str_int(self): + """ deserialize dict(str, int) """ + data = { + 'integer': 1 + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, ({str: (int,)},), True) + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['integer'], int)) + + def test_deserialize_str(self): + """ deserialize str """ + data = "test str" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (str,), True) + self.assertTrue(isinstance(deserialized, str)) + + def test_deserialize_date(self): + """ deserialize date """ + data = "1997-07-16" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (datetime.date,), True) + self.assertTrue(isinstance(deserialized, datetime.date)) + + def test_deserialize_datetime(self): + """ deserialize datetime """ + data = "1997-07-16T19:20:30.45+01:00" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (datetime.datetime,), True) + self.assertTrue(isinstance(deserialized, datetime.datetime)) + + def test_deserialize_pet(self): + """ deserialize pet """ + data = { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "fullName": "string" + } + ], + "status": "available" + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (pet.Pet,), True) + self.assertTrue(isinstance(deserialized, pet.Pet)) + self.assertEqual(deserialized.id, 0) + self.assertEqual(deserialized.name, "doggie") + self.assertTrue(isinstance(deserialized.category, category.Category)) + self.assertEqual(deserialized.category.name, "string") + self.assertTrue(isinstance(deserialized.tags, list)) + self.assertEqual(deserialized.tags[0].full_name, "string") + + def test_deserialize_list_of_pet(self): + """ deserialize list[Pet] """ + data = [ + { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie0", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "fullName": "string" + } + ], + "status": "available" + }, + { + "id": 1, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie1", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "fullName": "string" + } + ], + "status": "available" + }] + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, + ([pet.Pet],), True) + self.assertTrue(isinstance(deserialized, list)) + self.assertTrue(isinstance(deserialized[0], pet.Pet)) + self.assertEqual(deserialized[0].id, 0) + self.assertEqual(deserialized[1].id, 1) + self.assertEqual(deserialized[0].name, "doggie0") + self.assertEqual(deserialized[1].name, "doggie1") + + def test_deserialize_nested_dict(self): + """ deserialize dict(str, dict(str, int)) """ + data = { + "foo": { + "bar": 1 + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, + ({str: ({str: (int,)},)},), True) + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized["foo"], dict)) + self.assertTrue(isinstance(deserialized["foo"]["bar"], int)) + + def test_deserialize_nested_list(self): + """ deserialize list[list[str]] """ + data = [["foo"]] + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, ([[str]],), True) + self.assertTrue(isinstance(deserialized, list)) + self.assertTrue(isinstance(deserialized[0], list)) + self.assertTrue(isinstance(deserialized[0][0], str)) + + def test_deserialize_none(self): + """ deserialize None """ + response = MockResponse(data=json.dumps(None)) + + error_msg = ( + "Invalid type for variable 'received_data'. Required value type is " + "datetime and passed type was NoneType at ['received_data']" + ) + with self.assertRaises(ApiTypeError) as exc: + deserialized = self.deserialize(response, (datetime.datetime,), True) + self.assertEqual(str(exc.exception), error_msg) + + def test_deserialize_OuterEnum(self): + """ deserialize OuterEnum """ + # make sure that an exception is thrown on an invalid value + with self.assertRaises(ApiValueError): + self.deserialize( + MockResponse(data=json.dumps("test str")), + (string_enum.StringEnum,), + True + ) + + # valid value works + placed_str = ( + string_enum.StringEnum.allowed_values[('value',)]["PLACED"] + ) + response = MockResponse(data=json.dumps(placed_str)) + deserialized = self.deserialize(response, + (string_enum.StringEnum,), True) + self.assertTrue(isinstance(deserialized, string_enum.StringEnum)) + self.assertTrue(deserialized.value == placed_str) + + def test_deserialize_NumberWithValidations(self): + """ deserialize NumberWithValidations """ + # make sure that an exception is thrown on an invalid type value + with self.assertRaises(ApiTypeError): + deserialized = self.deserialize( + MockResponse(data=json.dumps("test str")), + (number_with_validations.NumberWithValidations,), + True + ) + + # make sure that an exception is thrown on an invalid value + with self.assertRaises(ApiValueError): + deserialized = self.deserialize( + MockResponse(data=json.dumps(21.0)), + (number_with_validations.NumberWithValidations,), + True + ) + + # valid value works + number_val = 11.0 + response = MockResponse(data=json.dumps(number_val)) + number = self.deserialize(response, + (number_with_validations.NumberWithValidations,), True) + self.assertTrue(isinstance(number, number_with_validations.NumberWithValidations)) + self.assertTrue(number.value == number_val) + + def test_deserialize_file(self): + """Ensures that file deserialization works""" + response_types_mixed = (file_type,) + + # sample from http://www.jtricks.com/download-text + HTTPResponse = namedtuple( + 'urllib3_response_HTTPResponse', + ['status', 'reason', 'data', 'getheaders', 'getheader'] + ) + headers = {'Content-Disposition': 'attachment; filename=content.txt'} + def get_headers(): + return headers + def get_header(name, default=None): + return headers.get(name, default) + file_data = ( + "You are reading text file that was supposed to be downloaded\r\n" + "to your hard disk. If your browser offered to save you the file," + "\r\nthen it handled the Content-Disposition header correctly." + ) + http_response = HTTPResponse( + status=200, + reason='OK', + data=file_data, + getheaders=get_headers, + getheader=get_header + ) + # response which is deserialized to a file + mock_response = RESTResponse(http_response) + file_path = None + try: + file_object = self.deserialize( + mock_response, response_types_mixed, True) + self.assertTrue(isinstance(file_object, file_type)) + file_path = file_object.name + self.assertFalse(file_object.closed) + file_object.close() + if six.PY3: + file_data = file_data.encode('utf-8') + with open(file_path, 'rb') as other_file_object: + self.assertEqual(other_file_object.read(), file_data) + finally: + os.unlink(file_path) + + def test_deserialize_binary_to_str(self): + """Ensures that bytes deserialization works""" + response_types_mixed = (str,) + + # sample from http://www.jtricks.com/download-text + HTTPResponse = namedtuple( + 'urllib3_response_HTTPResponse', + ['status', 'reason', 'data', 'getheaders', 'getheader'] + ) + headers = {} + def get_headers(): + return headers + def get_header(name, default=None): + return headers.get(name, default) + data = "str" + + http_response = HTTPResponse( + status=200, + reason='OK', + data=json.dumps(data).encode("utf-8") if six.PY3 else json.dumps(data), + getheaders=get_headers, + getheader=get_header + ) + + mock_response = RESTResponse(http_response) + + result = self.deserialize(mock_response, response_types_mixed, True) + self.assertEqual(isinstance(result, str), True) + self.assertEqual(result, data) + + def test_deserialize_string_boolean_map(self): + """ + Ensures that string boolean (additional properties) + deserialization works + """ + # make sure that an exception is thrown on an invalid type + with self.assertRaises(ApiTypeError): + deserialized = self.deserialize( + MockResponse(data=json.dumps("test str")), + (string_boolean_map.StringBooleanMap,), + True + ) + + # valid value works + item_val = {'some_key': True} + response = MockResponse(data=json.dumps(item_val)) + model = string_boolean_map.StringBooleanMap(**item_val) + deserialized = self.deserialize(response, + (string_boolean_map.StringBooleanMap,), True) + self.assertTrue(isinstance(deserialized, string_boolean_map.StringBooleanMap)) + self.assertTrue(deserialized['some_key'] == True) + self.assertTrue(deserialized == model) + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_pet_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_pet_api.py new file mode 100644 index 00000000000..38d7a1cc0b8 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_pet_api.py @@ -0,0 +1,406 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ docker pull swaggerapi/petstore +$ docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore +$ pip install nose (optional) +$ cd petstore_api-python +$ nosetests -v +""" + +from collections import namedtuple +import json +import os +import unittest + +import petstore_api +from petstore_api import Configuration +from petstore_api.rest import ( + RESTClientObject, + RESTResponse +) + +import six + +from petstore_api.exceptions import ( + ApiException, + ApiValueError, + ApiTypeError, +) +from petstore_api.api.pet_api import PetApi +from petstore_api.model import pet +from .util import id_gen + +import urllib3 + +if six.PY3: + from unittest.mock import patch +else: + from mock import patch + +HOST = 'http://localhost/v2' + + +class TimeoutWithEqual(urllib3.Timeout): + def __init__(self, *arg, **kwargs): + super(TimeoutWithEqual, self).__init__(*arg, **kwargs) + + def __eq__(self, other): + return self._read == other._read and self._connect == other._connect and self.total == other.total + + +class MockPoolManager(object): + def __init__(self, tc): + self._tc = tc + self._reqs = [] + + def expect_request(self, *args, **kwargs): + self._reqs.append((args, kwargs)) + + def request(self, *args, **kwargs): + self._tc.assertTrue(len(self._reqs) > 0) + r = self._reqs.pop(0) + self._tc.maxDiff = None + self._tc.assertEqual(r[0], args) + self._tc.assertEqual(r[1], kwargs) + return urllib3.HTTPResponse(status=200, body=b'test') + + +class PetApiTests(unittest.TestCase): + + def setUp(self): + config = Configuration() + config.host = HOST + config.access_token = 'ACCESS_TOKEN' + self.api_client = petstore_api.ApiClient(config) + self.pet_api = PetApi(self.api_client) + self.setUpModels() + self.setUpFiles() + + def setUpModels(self): + from petstore_api.model import category, tag + self.category = category.Category() + self.category.id = id_gen() + self.category.name = "dog" + self.tag = tag.Tag() + self.tag.id = id_gen() + self.tag.name = "python-pet-tag" + self.pet = pet.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet.id = id_gen() + self.pet.status = "sold" + self.pet.category = self.category + self.pet.tags = [self.tag] + + def setUpFiles(self): + self.test_file_dir = os.path.join(os.path.dirname(__file__), "..", "testfiles") + self.test_file_dir = os.path.realpath(self.test_file_dir) + + def test_preload_content_flag(self): + self.pet_api.add_pet(self.pet) + + resp = self.pet_api.find_pets_by_status(status=[self.pet.status], _preload_content=False) + + # return response should at least have read and close methods. + self.assertTrue(hasattr(resp, 'read')) + self.assertTrue(hasattr(resp, 'close')) + + # Also we need to make sure we can release the connection to a pool (if exists) when we are done with it. + self.assertTrue(hasattr(resp, 'release_conn')) + + # Right now, the client returns urllib3.HTTPResponse. If that changed in future, it is probably a breaking + # change, however supporting above methods should be enough for most usecases. Remove this test case if + # we followed the breaking change procedure for python client (e.g. increasing major version). + self.assertTrue(resp.__class__, 'urllib3.response.HTTPResponse') + + resp.close() + resp.release_conn() + + def test_config(self): + config = Configuration(host=HOST) + self.assertIsNotNone(config.get_host_settings()) + self.assertEqual(config.get_basic_auth_token(), + urllib3.util.make_headers(basic_auth=":").get('authorization')) + # No authentication scheme has been configured at this point, so auth_settings() + # should return an empty list. + self.assertEqual(len(config.auth_settings()), 0) + # Configure OAuth2 access token and verify the auth_settings have OAuth2 parameters. + config.access_token = 'MY-ACCESS_TOKEN' + self.assertEqual(len(config.auth_settings()), 1) + self.assertIn("petstore_auth", config.auth_settings().keys()) + config.username = "user" + config.password = "password" + self.assertEqual( + config.get_basic_auth_token(), + urllib3.util.make_headers(basic_auth="user:password").get('authorization')) + self.assertEqual(len(config.auth_settings()), 2) + self.assertIn("petstore_auth", config.auth_settings().keys()) + self.assertIn("http_basic_test", config.auth_settings().keys()) + config.username = None + config.password = None + self.assertEqual(len(config.auth_settings()), 1) + self.assertIn("petstore_auth", config.auth_settings().keys()) + + def test_timeout(self): + mock_pool = MockPoolManager(self) + self.api_client.rest_client.pool_manager = mock_pool + + mock_pool.expect_request('POST', 'http://localhost/v2/pet', + body=json.dumps(self.api_client.sanitize_for_serialization(self.pet)), + headers={'Content-Type': 'application/json', + 'Authorization': 'Bearer ACCESS_TOKEN', + 'User-Agent': 'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=TimeoutWithEqual(total=5)) + mock_pool.expect_request('POST', 'http://localhost/v2/pet', + body=json.dumps(self.api_client.sanitize_for_serialization(self.pet)), + headers={'Content-Type': 'application/json', + 'Authorization': 'Bearer ACCESS_TOKEN', + 'User-Agent': 'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=TimeoutWithEqual(connect=1, read=2)) + + self.pet_api.add_pet(self.pet, _request_timeout=5) + self.pet_api.add_pet(self.pet, _request_timeout=(1, 2)) + + def test_separate_default_client_instances(self): + pet_api = PetApi() + pet_api2 = PetApi() + self.assertNotEqual(pet_api.api_client, pet_api2.api_client) + + pet_api.api_client.user_agent = 'api client 3' + pet_api2.api_client.user_agent = 'api client 4' + + self.assertNotEqual(pet_api.api_client.user_agent, pet_api2.api_client.user_agent) + + def test_separate_default_config_instances(self): + pet_api = PetApi() + pet_api2 = PetApi() + self.assertNotEqual(pet_api.api_client.configuration, pet_api2.api_client.configuration) + + pet_api.api_client.configuration.host = 'somehost' + pet_api2.api_client.configuration.host = 'someotherhost' + self.assertNotEqual(pet_api.api_client.configuration.host, pet_api2.api_client.configuration.host) + + def test_async_request(self): + thread = self.pet_api.add_pet(self.pet, async_req=True) + response = thread.get() + self.assertIsNone(response) + + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + result = thread.get() + self.assertIsInstance(result, pet.Pet) + + def test_async_with_result(self): + self.pet_api.add_pet(self.pet, async_req=False) + + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + thread2 = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + + response = thread.get() + response2 = thread2.get() + + self.assertEqual(response.id, self.pet.id) + self.assertIsNotNone(response2.id, self.pet.id) + + def test_async_with_http_info(self): + self.pet_api.add_pet(self.pet) + + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True, + _return_http_data_only=False) + data, status, headers = thread.get() + + self.assertIsInstance(data, pet.Pet) + self.assertEqual(status, 200) + + def test_async_exception(self): + self.pet_api.add_pet(self.pet) + + thread = self.pet_api.get_pet_by_id(-9999999999999, async_req=True) + + exception = None + try: + thread.get() + except ApiException as e: + exception = e + + self.assertIsInstance(exception, ApiException) + self.assertEqual(exception.status, 404) + + def test_add_pet_and_get_pet_by_id(self): + self.pet_api.add_pet(self.pet) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched.id) + self.assertIsNotNone(fetched.category) + self.assertEqual(self.pet.category.name, fetched.category.name) + + def test_add_pet_and_get_pet_by_id_with_http_info(self): + self.pet_api.add_pet(self.pet) + + fetched = self.pet_api.get_pet_by_id( + pet_id=self.pet.id, + _return_http_data_only=False + ) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched[0].id) + self.assertIsNotNone(fetched[0].category) + self.assertEqual(self.pet.category.name, fetched[0].category.name) + + def test_update_pet(self): + self.pet.name = "hello kity with updated" + self.pet_api.update_pet(self.pet) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched.id) + self.assertEqual(self.pet.name, fetched.name) + self.assertIsNotNone(fetched.category) + self.assertEqual(fetched.category.name, self.pet.category.name) + + def test_find_pets_by_status(self): + self.pet_api.add_pet(self.pet) + + self.assertIn( + self.pet.id, + list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_status(status=[self.pet.status]))) + ) + + def test_find_pets_by_tags(self): + self.pet_api.add_pet(self.pet) + + self.assertIn( + self.pet.id, + list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_tags(tags=[self.tag.name]))) + ) + + def test_update_pet_with_form(self): + self.pet_api.add_pet(self.pet) + + name = "hello kity with form updated" + status = "pending" + self.pet_api.update_pet_with_form(pet_id=self.pet.id, name=name, status=status) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertEqual(self.pet.id, fetched.id) + self.assertEqual(name, fetched.name) + self.assertEqual(status, fetched.status) + + def test_upload_file(self): + # upload file with form parameter + file_path1 = os.path.join(self.test_file_dir, "1px_pic1.png") + file_path2 = os.path.join(self.test_file_dir, "1px_pic2.png") + try: + file = open(file_path1, "rb") + additional_metadata = "special" + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata=additional_metadata, + file=file + ) + except ApiException as e: + self.fail("upload_file() raised {0} unexpectedly".format(type(e))) + finally: + file.close() + + # upload only one file + try: + file = open(file_path1, "rb") + self.pet_api.upload_file(pet_id=self.pet.id, file=file) + except ApiException as e: + self.fail("upload_file() raised {0} unexpectedly".format(type(e))) + finally: + file.close() + + # upload multiple files + HTTPResponse = namedtuple( + 'urllib3_response_HTTPResponse', + ['status', 'reason', 'data', 'getheaders', 'getheader'] + ) + headers = {} + def get_headers(): + return headers + def get_header(name, default=None): + return headers.get(name, default) + api_respponse = { + 'code': 200, + 'type': 'blah', + 'message': 'file upload succeeded' + } + http_response = HTTPResponse( + status=200, + reason='OK', + data=json.dumps(api_respponse).encode('utf-8'), + getheaders=get_headers, + getheader=get_header + ) + mock_response = RESTResponse(http_response) + try: + file1 = open(file_path1, "rb") + file2 = open(file_path2, "rb") + with patch.object(RESTClientObject, 'request') as mock_method: + mock_method.return_value = mock_response + res = self.pet_api.upload_file( + pet_id=684696917, files=[file1, file2]) + mock_method.assert_called_with( + 'POST', + 'http://localhost/v2/pet/684696917/uploadImage', + _preload_content=True, + _request_timeout=None, + body=None, + headers={ + 'Accept': 'application/json', + 'Content-Type': 'multipart/form-data', + 'User-Agent': 'OpenAPI-Generator/1.0.0/python', + 'Authorization': 'Bearer ACCESS_TOKEN' + }, + post_params=[ + ('files', ('1px_pic1.png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82', 'image/png')), + ('files', ('1px_pic2.png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82', 'image/png')) + ], + query_params=[] + ) + except ApiException as e: + self.fail("upload_file() raised {0} unexpectedly".format(type(e))) + finally: + file1.close() + file2.close() + + # passing in an array of files to when file only allows one + # raises an exceptions + try: + file = open(file_path1, "rb") + with self.assertRaises(ApiTypeError) as exc: + self.pet_api.upload_file(pet_id=self.pet.id, file=[file]) + finally: + file.close() + + # passing in a single file when an array of file is required + # raises an exception + try: + file = open(file_path1, "rb") + with self.assertRaises(ApiTypeError) as exc: + self.pet_api.upload_file(pet_id=self.pet.id, files=file) + finally: + file.close() + + # passing in a closed file raises an exception + with self.assertRaises(ApiValueError) as exc: + file = open(file_path1, "rb") + file.close() + self.pet_api.upload_file(pet_id=self.pet.id, file=file) + + + def test_delete_pet(self): + self.pet_api.add_pet(self.pet) + self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key") + + try: + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + raise Exception("expected an error") + except ApiException as e: + self.assertEqual(404, e.status) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_serialization.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_serialization.py new file mode 100644 index 00000000000..1f718ecca6b --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_serialization.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd OpenAPIPetstore-python +$ nosetests -v +""" +from collections import namedtuple +import json +import os +import time +import unittest +import datetime + +import six + +import petstore_api + +from petstore_api.exceptions import ( + ApiTypeError, + ApiKeyError, + ApiValueError, +) +from petstore_api.model import ( + enum_test, + pet, + animal, + dog, + parent_pet, + child_lizard, + category, + string_enum, + string_boolean_map, +) +from petstore_api.model_utils import ( + file_type, + model_to_dict, +) + +from petstore_api.rest import RESTResponse + +MockResponse = namedtuple('MockResponse', 'data') + +class SerializationTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.serialize = self.api_client.sanitize_for_serialization + + def test_enum_test(self): + """ serialize dict(str, Enum_Test) """ + value = ( + string_enum.StringEnum.allowed_values[('value',)]["PLACED"]) + string_enum_val = string_enum.StringEnum(value) + + source = enum_test.EnumTest( + enum_string="UPPER", + enum_string_required="lower", + enum_integer=1, + enum_number=1.1, + string_enum=string_enum_val + ) + + result = { + 'enum_test': { + "enum_string": "UPPER", + "enum_string_required": "lower", + "enum_integer": 1, + "enum_number": 1.1, + "stringEnum": "placed" + } + } + serialized = self.serialize({"enum_test": source}) + + self.assertEqual(result, serialized) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_store_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_store_api.py new file mode 100644 index 00000000000..a7c1d5dd667 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_store_api.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd OpenAP/Petstore-python +$ nosetests -v +""" + +import os +import time +import unittest + +import petstore_api +from petstore_api.api.store_api import StoreApi + + +class StoreApiTests(unittest.TestCase): + + def setUp(self): + self.store_api = StoreApi() + + def tearDown(self): + # sleep 1 sec between two every 2 tests + time.sleep(1) + + def test_get_inventory(self): + data = self.store_api.get_inventory() + self.assertIsNotNone(data) + self.assertTrue(isinstance(data, dict)) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/util.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/util.py new file mode 100644 index 00000000000..113d7dcc547 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/util.py @@ -0,0 +1,8 @@ +# flake8: noqa + +import random + + +def id_gen(bits=32): + """ Returns a n-bit randomly generated int """ + return int(random.getrandbits(bits)) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tox.ini b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tox.ini new file mode 100644 index 00000000000..8989fc3c4d9 --- /dev/null +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=petstore_api diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py index 3276615fd49..1746d5c1a90 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py @@ -434,27 +434,43 @@ class ModelComposed(OpenApiModel): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -464,13 +480,12 @@ class ModelComposed(OpenApiModel): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1573,8 +1588,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1582,20 +1602,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1655,31 +1663,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1736,24 +1722,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1766,47 +1736,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1850,36 +1807,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py index 7edd9487c37..3dc0d4e47e2 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py @@ -434,27 +434,43 @@ class ModelComposed(OpenApiModel): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -464,13 +480,12 @@ class ModelComposed(OpenApiModel): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1573,8 +1588,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1582,20 +1602,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1655,31 +1663,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1736,24 +1722,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1766,47 +1736,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1850,36 +1807,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] diff --git a/samples/openapi3/client/petstore/python-experimental/.coverage b/samples/openapi3/client/petstore/python-experimental/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..9e8563e13450422ac584dd73f6572a2d6b14b7cf GIT binary patch literal 94208 zcmeHw34B!Lx%ZiwGy7SxkUb$oSVADlB!qoS2(p8$0R&-kGIJ&wG8?mm1aBc{?A0#z zyIQ~2rM2R{-q!03Rwt3bMGtG0M;FV(t`UfXKb3NF3i2a@|d@0pp*gv3w3ANHl* zGmz(*=e+MZ^FRN0-#2eu>x;<_ZzvLwVvZ&zhtcVn7Kejj7%Ti0!C&fQhA(W&0IkdT zKGs(&Q@`d$UfjxXrmr*NZhpI1$NekswEvFlvEFR|j(LyO4-VQ#V?bj-V?bj-V}LNA zY~;*EB_+DV=VDTaUyem2w;WL=zjV{GC0mv`wk&B~yUd|pb4;~4;8R!USmKC;_Bq0G z#NqY%Wrr{5@wug#FWBjbb;&8;@u=*<5)ZCHnTH)T;Hgi#azV3RN zypt4h!+(3$+rWk4S6StS2f0HL52EjgNI`d(9IbUo={IzT0B3JZecMPV;EaVFeqWHh zW-#iD`9eX5+$+1|G1)Wf3)UiOsSl8s`8M#Zc6_0B_0HsPWw0}R^C)*Fy(e$>0=Qr( zMeFd5_|tGR!5oYSI)L&$@jw^@2kuaRI2Ib~&av)|g_1A(vBPGRupEBhtl&&hjv=bv z6%YFM#^rS2*E)vptR=4z4AnaDB_IY&wwsFPE~>25UB8z^6r{)1;fqDnU#wY?CVhE~sDtif#~Vx~*^vZOk>BqKc}bGNyB%ua zKy1!TGtLwlQUnv4Bb4+ANU6p)1Pd4(9sW>9c3dMdCMrV$fxIB)%^MH8F{woH9o(TF zIU;q+^+{JXTc910AnG()O-0Kp$BH`XDBx;Lf3+zkCUa3)nJ!@^(I^>ONoCH8LaC4( zB^ymS1!O52kEAk^kIE!dcMRu}sWg&wf!C=sn~Ii{jrBT7f3C*l7mH$M%|!(TIz>$p zm@na}SHN-n4Z}_3;{FLFS?vkRI`9!N79ifn4mV#=L03KIG;ir622l?rX3!~=YXGHt( z8J#`V1WKw*!Q6cdq_tGCf-ix96!avEDJ*@}r$UyGX%c@&%{$;mM>V9yD5T60&rCfu z>53Uu>iP9ypaP#7kUVNC$FRtF;=V5VqQ|L)&=pclj`;$z1HBM1BtGqvq7HXN21h7D zYpM+&75W%Ru11vDO15A{Myb@9i>6Q4De+_)RI?XX6w2~|l!Bc!^;vOagyV2DSr7Rv zRB|$-2XdD|2b$_HV4kLiV28>=%2%?AW2@l-rA|D@z<=$dF`zM^F`zM^F`zM^F`zM^ zF`zM^F`zM^F`zN<*<-+<)9cLG{%6I>Fg7o)7n|UV_R$#77|L{%gQ1`arwPnxn9*3*Fr#k9Tt`FW{28<7H_qkthO+$R zAp5NPnK1s(RwSBIvmgkoe?PzfN6ftP*@I1VP9RR z9E5pDu~5Vrl>%YE98I}2Io*Dr9E>@`ax4n&vNPNl>k0+y0d3!(=(8mq2#RM*wPq=H4MJ6-TY)w^sErmXlJBR(g-FTO6G{GS@c+IwpZXbfl! zXbfl!Xbfl!Xbfl!Xbfl!Xbfl!{CzRN87g$Cz6#c2D9~Y7g~4tp(Q^mapqHPt0y zgqLH*x9}AU#dG3+iSLMSaXaiM>}zaCZ8NNQTT3k0n2(!VO+PR>jdvM~+3O7#3?cn% z`klHT>#CTWE;%=fP|h-m34fc8lFYskXCUN}{Z1(ok@{RAuSQL$GEl;_^z} zup&3?LqMi+l$b$4E|)Lpi@96~#GVg8%BTgA6of_aexN22AhhIBq9vI-6Eq0KoC`qm z>CxixKsqAjgDnS;lu$#0<&?|qmsBt{B7oUO4UFXRkc|f*#=y7+3`xX%a@4iY7wdxM zp(6{{G6AqIxXiGonY8eLu7Dc4fE0G&zzxX)IDkSg3xH++usKv3jnxil=oRZEzNeV6 z*#HZ@w5P`D6c~$@YK+M&G;|h#Vx|yzqp%$c)B_>b9y9|40|f}_io4MS2&mQhT=AIC zPYMXL5pd8bs$l;Fudg!>BgwFg9y1b_1tdI;FzI#6VY1Bzz&Kz46gmnhpu{HmDXXVM z1Jv!HsKx<&3=O>wU|9clJV0B0TmVGgCJ?!EK;)F`h1VIDuZHhTkr?8ug*N^d{M+_5 z*y>l?{F$wN+fl;>bF11fz`Z2I?I-ZYOZrhnHZg%lyN=6^mlT1GVg^Aro4$frn4y7`~0*x5u0JtSGp{~To+ zo7hGV%qMC7i%L10Sa7*vO*Q`o#mXiM=%LGK{_~Wxfb8Z!N4Z$fZ2sFRr@gG^zm0N? z$!Pvt6+N3U(}=vo&3}u+un7YV45{|N`4U$8pov2}zmoUHeSX-8E&_e4v4~F!cEaeE z~Z!-?0(kI?qb)oOV~QL!f?CcOYpMVM`M68135jc&RW%DX@?Cs3@yi>2{#FGxH3Mj zUTF^s3KKKxtO+J&X*YOI>yvoT?z`{)?!GBWYv9;UdDqiTx}CWi6y>P8`uj;3P3!@cAtDWKa5Lo3QVjb%AazS(qs$SV;0eC&d z7P#p3UX0`?F&{nrwYERro-~*XFYgIvyus;HTd(?U#LM~dp?>wDbNO!k#cpDCFa~}P zntN2o_9oE>ro%_fqq>H{>3kQucctAs(YUx z_+jHg-Q4A$8ay!SJMxcv(AP~gRL=PMw1zWyYh z9Lu!7_{fF_Jd#JoYMZ^X{$q zF#P<(shx7$ky|=b;d}Z>=xc3%-5pFljyZkg)U^BFIPwyg-wuGMwjUFwwq`_*6-Urj6{w-cRqs!kUB z4s_aqR=cD4DlleTr8+T;`-aBrO1wY!{+}Ck{C03D->$kmq!+elW1-Fz}nv+>B;R12dc7gytsI72?E3FdZ9-c~r-pwQ(EZLg@y) z08yA*kJkF6#b1f{UP&yB(Cg4~oodeG*P`QEVhuDk@oUgrlQj2ntI_XjG#NvKxC$)C zDzt#-_EVy`5-+SI&KNc4i!1QLiu8pe+;V)ta`gf2+%mM5sg|SU3b1Bgk)4!YdEnvi z{?RKg#pf(lJu(ABvvXSELRBkXXg}n7^s&dH!Vh@##Fm8+$NzEaLI8BW`Pw2i7D57s zDE^I94wP*T1tBB*C5isv`y;G@V-MUv?YAk9Y9^4%03kbsEaBr>k0Cj!1d*MqGH1_x z_u+eYWo4upo&n$KBSQyWAHH_t_7nF;?}g8Wp$kLru1&rs+z7^-CH_Me|{!!E?k*1H|eGSohSRx=yT`5wMlc5*GR6FGaGN5O)e#L{ZB9k zaTZ*0%u0G{7_85oiFeJ!3j+r^=9Oz+U&J-RrP3zi$6yg>;2krPcNCv4;2YsWc_Utc zNMR^y0JEVXGl~wL+`9E^-JBC2<3xY$OgUGNR(;aq>+l(MA6aDtV}tM zN5}DK4KT$#SAmWds^b7xj#fEZbGg%e8G0>K-C8)V6dg;^?APh}5_Bw49U;do26KF| zYTj7!KI}XMo{Lm_kSj#1P_-;21z^oA$P65YM9fD^U>_WvRT!t|^6`dzyurdX zm4_DOUjxsdGjO@+o~u5P<#WI)&q1plGD==VQzYIS`^};NrbAHuGT#innZv_{DjqLD zT=_%HJG+d7D|5M|7v|Ze)z`ef_WJR)=iYjDiCAVwM?3M(G%(D5?{$lsmUdqEs~Z}h zC>Cw_a9i?O4IN!3D_jt)`q>uHK?{5O;Gr#Fbyqg2$u&n+EueBxz;v5tveDL)5hKCN{I*X|p z8vk=H*95k1N}hvp=b`M}Vbp?v<_+qa)PHgrtK{4jJ(cVOrT=RP>q__Lwoi-tb@ze8tQhtA}b zG8=yM`v=dQe0iw-!l@Sqm>lpMtk?hX*z9)Kt1tYv_laBHS>N38@>gFtb?S!BW5=4l z#Xo=OI@g?>YybU2S6^T2cd+)uKYwt1=qE!rGq1ll zZ?ONMY3|^iQ)Uk|8_vIX@Pp4Gxj=dB9bF;gP^pI6>w!wO3Y!cJVjzW#dbuCIp$PrJvzWvOkW*za|pW&DaMHYWV^@*?@V%_&C9;5UwE`iJlR`WtU6p7@K&^Hx<& z`eOg2oAmud5@Q%(xQ6zD_WoJ@Iy*qO7+8yi)f-#R9z1Zi(&D-HrIxSoMJzDkkF zni&(*zkl1R0p```hMFIJZ9$^{wtFhkv#I5!b<7nFCx#B9#V~`Fgc$s)@XU79I%dgg z-HiswOWNep&py_&Kph42fN$B<>J5i)+PY;$m@* z*dW%3RbrVqPUJE+#!5j_$T2Df+Fk} zqJm$Lh26q7VS}(rXcZO+Gle=~icl#O3%P<#F!1O3zw&SMuknNY3;c8Z)BI2QBm5)$ zgZw@GUHt9*&HN4gKk^6oeSDbr@g4k5eha^jU(Pr4bNNPo8b6UQ=L>j&hZ7FD54d-s zN8=CN%iIa>IJ~U((HPJe&=}Ad&=}Ad&=}Ad&=}Ad_`7Dn1nn$cPY+S?I8m_}QPC(- zkqA+H_YxHj6BP;(6$}y;2oUA>6V=^K)Sf*=`FuombrIFsNtD-1lq?hF@et*96V=f{ zlq3<=-cFRuMbz%yMD5x|)YVrLwR0y?J9ZFt)m21o-%ixFZA5L|N>p1LQCqeUwRtm9 zn>G=(aU)S1HW0ObJyBO)Nz}S^M6F#*)S5L!tzJ#ks#Qd-TuIc56+|sxPSmnxL|t(O zQA?K+)!Itbk|jj7v=G(YOw{7VL@ioG)WU^CEm%O*{P{%9n@7~#xkSyGL)7fqM9rE- z)XbSgH8l}6V+K);jYKsx5ao0dRbNk3T^&)iwM0#yPSmt%MAg&~HFYXc)zw5znL^a$ z$wW<>MAXEIL{(K0HDLl#4hK<{l|+pnPgF$(QRU@Cm6Z`yT1r$&2~owxL=_bgRai(= zK><U}0ibM$lQ9Mr+#}Q?>6J@gzWwjDzu@Gf86J;_HWrU3| zA$71UQ3eB1dOZuB0A&0hJ7lzv#(>6v#(>6v#(>6v#(>6v#(>6v#(>6v#(>7aXO{sS z|JU08pWX1)-b`aaV?bj-V?bj-V?bj-V?bj-V?bj-V?bj78Nl`bz5G2m|Npgx6txz$?NF z!f%A*!c)S}V2!|I!Xv`>g!_f>2>%T01a1{>7XFv;Md9|w&%*kF zC-@)nkMoE5hxrHKg|&~yfX0BvfX0BvfX0BvfX0BvfX0Bvz-7vSp%*r5H|#^vgCdS1 zh9Zh0f?_X&u>!?%6w6Rt zfnq6&RuoH6w4i84u^7c76bn%-KrtW1JQQnTk3yPOjajl(LCAqabvKBcaZS6bSf&oz75L4#Jz&b;?0F4i$)YMx{X5FGo`@ zO-}V_d3<*g5Kf2=U7=u|+#8l7z5twVD*4ln$c_{Lyi&L9A}2rxrGV^;Nu5zwz04|Kwf&_D9wayDL^wf$>tVMfduN3#E+8hnkDq@I53Wj1`P%F%+Jr__b9uQDQ z`W>g}*@V^VY=b6i)VU`fjroEde#zbaske19K-k!um{Q$DMt8q%BKtLAm;Orrw|pyi zn450D)o!yX)<0WUTW&L-G4C<`(lpEXps`BqVGV{J;SK#s=0@fzXo`F({}LvC_9mT! zVlC9`gSuYS-6aPkS4@t^ur)|6zNn>mhZKZ=kg6*c2b&nJ_5P{Hmt=KVXVNMX>h_w7&R$5jg5#;LqF?(<7A=%nzwViBJd>?GCq z`HG!QP;9_s!KwChK%nJNuDla4q!x%#XdZu@VJXw2rnqF2&p{cCCj_lwzaM%yfSo3V zWfS&GnB9Kt?lCoi0T@6rLn&kvPKqcXMX8O4jC=@iIh8UtF^@8?81ycV2CklVJc34Y zw96ItVF=byE=t^?KsXeYJ}F=#?d%K9~>GDo!>b(F@BoLhOmU7@;c| za%D%p=}HBgSVR}FU+#77jZ2*E~co5DtlxtV%Hd7(xVvuw&xJWh& zv`kfU*~Dauv8l`F_qf~=wBk}_Pc^khWwLUYf&}zTq1+1t#K@hY2o5w%rkt;5h0!Ev zj#(-p+EA`104ShlB4uhir0CwboGkJtP>#N&nu|?JAjVFu!zx*gi%9!mlm(E?#QFc_ z%uS4Vjqtt@ku^jL8_)Q*;)9Vx|yzqrT3d+O#-m1_%ZU5HNyZ7oq~& zo>Q#zx#BUOpWrYX0SAquYUK0;=oJ7YJdH5PoH26104QkmZNY3PY013THK-LJYVweG7>=d%tBrRlwRw-%(6iw7n_=0{P zjO?YR2)mL~!Z7cJV^ZnV9;4nBFkCj88$!^V@8`VZZ)){Yu>rV9~(!m#q1(lxzZa=1^nD7Y#+- zGOQp^Pt(pQx$-swwwlWb8x~>w1^`t_4^$9lK*7QqSdZU0i{M#*dEk+H8ygT$<&}Vk zUWVXH@CZ0HarV%mUUy<|`}Q8h}J^ z+C(NK47$A40Eb?V&?QC5J_k?=OE`y`?0BH$t)dDFcIOCs!V;Oqtxg(1rYtJ~6up{u zXTX*2u(YlKDD)a21V^ggWLOSZ=vB16p%4ZRy9`j!7!FeVDsizL!YH`{V9+T0u}koy z_k2;@8*Sipf#cQxD2Nq_CrfdnIp*L|O)Uii)$JDv<>QbAC>?Iou zkm1&%7C=X@?>jj=b7Wfpc{4QwGJ3700BoNm`4LF|VgNFoTII1zmi(~w11z(3cjF)d ztQJR9g^K_cy$aE2Yk$e^8H#BkrEp7UQ1FE$yafP+Ucwt~Icr8cY2183N3VrD8agD+ zJ`Z5g%R5O6fV93z?!?apH1yhSWEj~MiokYRe#{E+{J&!TB1XT+uv-69F(SMn?B;*X zFXsM@%eVL0-mq=69<`QRZh&5ZPSew-R^wqK3$p-T)!n7bVGd-q|CM|;QKS1rnF_-g zU7H81iirG!n)Qp1eeZYNpw$7PfkJE@iF z<&^hN8?*FUM0ph!2`iW1N2Xr2DS2$7nqG=0U}iKlV67vyd)XGHkxj@HG5LC7C3MEV zSkR7kjXse&l?XReUjLXeIhm)tfHz&KZKk$$sG1vnR2TB5|BtfqQWkUuf+>u?#S5hu>vJhr=A+Mvnd_4=8+J(H9 z@|KyIkRb7`QHt3_6V1do)(pKyWgMHBP7m4Wodb(0=b)o@xv!=SYSb?GRg~)n8C~ux zDX+QD>~dd0dF$TPFvKj%`;25S=Hk@x|3i$pPIy$PuVaYYQZ0oDa~^ z>z^DA9gCAI?!2ZQ@H#Cm^FY5nv=TBun%Hq>0qpEa?Gvm)93j7n2pq zRD&;jzb~w1M!b@nm}=ZjDQMK5kx;~=M%1ERfP-GqkQ`_q zZ74hEYCuM>Xh_& z9RSUu2PiapFFR%c>^6W#Z)Q}gcF%1E81$w+s!ffE9E(TrbOXiK25{)*(JGweNRpDf z1;A8Oi#-I)h>;|vVKZQo>0$chBS|>^KaRbdF)OA&nc9p$HO^q~7QMo+g<1SJ_APYU46r|O1mfzC67b~nNug_Ea2i!NH68!%j)Wb6M=?1A!W*wIV zS4ww6x+%|ER68L%XrmzgZS9n&C}ws3x#-rWovF^h-IUYx*qwj7lyWw)fL;YViHwx3 z7q9grEBtP%0W5ylB5ITV#IFYDWQ?Sk9Tli=Je3!f7jLpm$i?^fX0Bv zfX0BvfX0BvfX2Yz5d(^~7lxy#?RXK*JnULA?*lB9=5b~tG4=ow8uM<{&cOY0M+A>^ zR*Z3~IQDhHyg$TYiUAH9)3R_L5{}tmUory8ivkdO6KqolG-vf+DV7L;qPKxf3Ka5V z*b7kTOH0c%6ao`@GWM8ewq!>}Cj1>|5%^5a6I^eS4X+5?i&Qi2TT@}GZ5p;Q=kv9F)< rM9A#LzTK2(0gSesc6i#@9;JXy)KSbGMp=psk=;jmI@HMR|K|QTNzD)V literal 0 HcmV?d00001 diff --git a/samples/openapi3/client/petstore/python-legacy/pom.xml b/samples/openapi3/client/petstore/python-legacy/pom.xml index 98955483eb8..3a9cf727306 100755 --- a/samples/openapi3/client/petstore/python-legacy/pom.xml +++ b/samples/openapi3/client/petstore/python-legacy/pom.xml @@ -1,7 +1,7 @@ 4.0.0 org.openapitools - PythonOAS3PetstoreTests + PythonLegacyOAS3PetstoreTests pom 1.0-SNAPSHOT Python OpenAPI3 Petstore Client diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index aa906bc845d..d2f40afcb98 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -28,6 +28,7 @@ docs/ClassModel.md docs/Client.md docs/ComplexQuadrilateral.md docs/ComposedOneOfNumberWithValidations.md +docs/ComposedSchemaWithPropsAndNoAddProps.md docs/DanishPig.md docs/DefaultApi.md docs/Dog.md @@ -134,6 +135,7 @@ petstore_api/model/class_model.py petstore_api/model/client.py petstore_api/model/complex_quadrilateral.py petstore_api/model/composed_one_of_number_with_validations.py +petstore_api/model/composed_schema_with_props_and_no_add_props.py petstore_api/model/danish_pig.py petstore_api/model/dog.py petstore_api/model/dog_all_of.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 61aebac0aa1..266472605a2 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -157,6 +157,7 @@ Class | Method | HTTP request | Description - [Client](docs/Client.md) - [ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [ComposedOneOfNumberWithValidations](docs/ComposedOneOfNumberWithValidations.md) + - [ComposedSchemaWithPropsAndNoAddProps](docs/ComposedSchemaWithPropsAndNoAddProps.md) - [DanishPig](docs/DanishPig.md) - [Dog](docs/Dog.md) - [DogAllOf](docs/DogAllOf.md) diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md index 460813c1223..b8d54e3c9bf 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md @@ -10,8 +10,9 @@ Name | Type | Description | Notes **map_with_undeclared_properties_anytype_1** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional] **map_with_undeclared_properties_anytype_2** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional] **map_with_undeclared_properties_anytype_3** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional] -**empty_map** | **bool, date, datetime, dict, float, int, list, str** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] +**empty_map** | **dict** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] **map_with_undeclared_properties_string** | **{str: (str,)}** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithArrayOfEnums.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithArrayOfEnums.md index 49ca7b3d754..5cdb2f4c922 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithArrayOfEnums.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithArrayOfEnums.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**any string name** | **[EnumClass]** | any string name can be used but the value must be the correct type | [optional] +**any string name** | [**[EnumClass]**](EnumClass.md) | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Animal.md b/samples/openapi3/client/petstore/python/docs/Animal.md index 1d1c77c01ab..d36c66a5d88 100644 --- a/samples/openapi3/client/petstore/python/docs/Animal.md +++ b/samples/openapi3/client/petstore/python/docs/Animal.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/AnimalFarm.md b/samples/openapi3/client/petstore/python/docs/AnimalFarm.md index fc299cf27d3..fb3b33c9c9c 100644 --- a/samples/openapi3/client/petstore/python/docs/AnimalFarm.md +++ b/samples/openapi3/client/petstore/python/docs/AnimalFarm.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | [**[Animal]**](Animal.md) | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ApiResponse.md b/samples/openapi3/client/petstore/python/docs/ApiResponse.md index 81a7d0d8522..bedefea9a9c 100644 --- a/samples/openapi3/client/petstore/python/docs/ApiResponse.md +++ b/samples/openapi3/client/petstore/python/docs/ApiResponse.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **code** | **int** | | [optional] **type** | **str** | | [optional] **message** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Apple.md b/samples/openapi3/client/petstore/python/docs/Apple.md index d8ba5ec0711..d7634278906 100644 --- a/samples/openapi3/client/petstore/python/docs/Apple.md +++ b/samples/openapi3/client/petstore/python/docs/Apple.md @@ -4,8 +4,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**cultivar** | **str** | | [optional] +**cultivar** | **str** | | **origin** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md index 6ab77963788..11cd25c98ee 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_array_number** | **[[float]]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfEnums.md b/samples/openapi3/client/petstore/python/docs/ArrayOfEnums.md index d2f8ea80a3d..f1593c10afd 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfEnums.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfEnums.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | [**[StringEnum]**](StringEnum.md) | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md index ebc65a54ba7..1e9bb12e4e8 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_number** | **[float]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ArrayTest.md b/samples/openapi3/client/petstore/python/docs/ArrayTest.md index 4e1bda8fc3a..9eac1f8874c 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayTest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **array_of_string** | **[str]** | | [optional] **array_array_of_integer** | **[[int]]** | | [optional] **array_array_of_model** | [**[[ReadOnlyFirst]]**](ReadOnlyFirst.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Banana.md b/samples/openapi3/client/petstore/python/docs/Banana.md index 54e06a1de59..2e38614e0f8 100644 --- a/samples/openapi3/client/petstore/python/docs/Banana.md +++ b/samples/openapi3/client/petstore/python/docs/Banana.md @@ -4,7 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**length_cm** | **float** | | [optional] +**length_cm** | **float** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/BasquePig.md b/samples/openapi3/client/petstore/python/docs/BasquePig.md index 6c583c5bc9f..0d92ecbe02b 100644 --- a/samples/openapi3/client/petstore/python/docs/BasquePig.md +++ b/samples/openapi3/client/petstore/python/docs/BasquePig.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Capitalization.md b/samples/openapi3/client/petstore/python/docs/Capitalization.md index 1ddeadeb3f4..df9989f8db5 100644 --- a/samples/openapi3/client/petstore/python/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/python/docs/Capitalization.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **capital_snake** | **str** | | [optional] **sca_eth_flow_points** | **str** | | [optional] **att_name** | **str** | Name of the pet | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/CatAllOf.md b/samples/openapi3/client/petstore/python/docs/CatAllOf.md index 0ff7809a99a..6fd1390a749 100644 --- a/samples/openapi3/client/petstore/python/docs/CatAllOf.md +++ b/samples/openapi3/client/petstore/python/docs/CatAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **declawed** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Category.md b/samples/openapi3/client/petstore/python/docs/Category.md index 940f6a45e64..7650eccafba 100644 --- a/samples/openapi3/client/petstore/python/docs/Category.md +++ b/samples/openapi3/client/petstore/python/docs/Category.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | defaults to "default-name" **id** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ChildCatAllOf.md b/samples/openapi3/client/petstore/python/docs/ChildCatAllOf.md index c5883b9a87c..c5b2f58f28c 100644 --- a/samples/openapi3/client/petstore/python/docs/ChildCatAllOf.md +++ b/samples/openapi3/client/petstore/python/docs/ChildCatAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ClassModel.md b/samples/openapi3/client/petstore/python/docs/ClassModel.md index 48ed7cbf2ff..6605a16d74a 100644 --- a/samples/openapi3/client/petstore/python/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/python/docs/ClassModel.md @@ -6,6 +6,7 @@ Model for testing model with \"_class\" property Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_class** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Client.md b/samples/openapi3/client/petstore/python/docs/Client.md index c3986008d6c..1b293140f34 100644 --- a/samples/openapi3/client/petstore/python/docs/Client.md +++ b/samples/openapi3/client/petstore/python/docs/Client.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **client** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ComposedSchemaWithPropsAndNoAddProps.md b/samples/openapi3/client/petstore/python/docs/ComposedSchemaWithPropsAndNoAddProps.md new file mode 100644 index 00000000000..5930b762b0c --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/ComposedSchemaWithPropsAndNoAddProps.md @@ -0,0 +1,13 @@ +# ComposedSchemaWithPropsAndNoAddProps + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**color** | **str** | | [optional] +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/docs/DanishPig.md b/samples/openapi3/client/petstore/python/docs/DanishPig.md index dd7fe16ea4a..4d1ebe4f68a 100644 --- a/samples/openapi3/client/petstore/python/docs/DanishPig.md +++ b/samples/openapi3/client/petstore/python/docs/DanishPig.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/DogAllOf.md b/samples/openapi3/client/petstore/python/docs/DogAllOf.md index 6382bbd8067..2907a9fd5c4 100644 --- a/samples/openapi3/client/petstore/python/docs/DogAllOf.md +++ b/samples/openapi3/client/petstore/python/docs/DogAllOf.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **breed** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Drawing.md b/samples/openapi3/client/petstore/python/docs/Drawing.md index 0f0390a3f72..a4fc4830562 100644 --- a/samples/openapi3/client/petstore/python/docs/Drawing.md +++ b/samples/openapi3/client/petstore/python/docs/Drawing.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **shape_or_null** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] **nullable_shape** | [**NullableShape**](NullableShape.md) | | [optional] **shapes** | [**[Shape]**](Shape.md) | | [optional] -**any string name** | **Fruit** | any string name can be used but the value must be the correct type | [optional] +**any string name** | [**Fruit**](Fruit.md) | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/EnumArrays.md b/samples/openapi3/client/petstore/python/docs/EnumArrays.md index 9be5c645a80..ad4e9d2fcb7 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/python/docs/EnumArrays.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_symbol** | **str** | | [optional] **array_enum** | **[str]** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/EnumClass.md b/samples/openapi3/client/petstore/python/docs/EnumClass.md index a1f9aae5819..39bb0e1644c 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumClass.md +++ b/samples/openapi3/client/petstore/python/docs/EnumClass.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **str** | | defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/EnumTest.md b/samples/openapi3/client/petstore/python/docs/EnumTest.md index b9181858434..27b6997e695 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/python/docs/EnumTest.md @@ -15,6 +15,7 @@ Name | Type | Description | Notes **integer_enum_one_value** | [**IntegerEnumOneValue**](IntegerEnumOneValue.md) | | [optional] **inline_array_of_str_enum** | [**[StringEnum]**](StringEnum.md) | | [optional] **array_of_str_enum** | [**ArrayOfEnums**](ArrayOfEnums.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/File.md b/samples/openapi3/client/petstore/python/docs/File.md index 63b1d1a6518..f84547d1933 100644 --- a/samples/openapi3/client/petstore/python/docs/File.md +++ b/samples/openapi3/client/petstore/python/docs/File.md @@ -6,6 +6,7 @@ Must be named `File` for test. Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **source_uri** | **str** | Test capitalization | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md index caf2440821d..4572aa0905b 100644 --- a/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **file** | [**File**](File.md) | | [optional] **files** | [**[File]**](File.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Foo.md b/samples/openapi3/client/petstore/python/docs/Foo.md index 23fb5e1678e..c9c54d1ee40 100644 --- a/samples/openapi3/client/petstore/python/docs/Foo.md +++ b/samples/openapi3/client/petstore/python/docs/Foo.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **str** | | [optional] if omitted the server will use the default value of "bar" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/FormatTest.md b/samples/openapi3/client/petstore/python/docs/FormatTest.md index 4fcec135190..3c8cc8697c1 100644 --- a/samples/openapi3/client/petstore/python/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python/docs/FormatTest.md @@ -20,6 +20,7 @@ Name | Type | Description | Notes **uuid_no_example** | **str** | | [optional] **pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional] **pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Fruit.md b/samples/openapi3/client/petstore/python/docs/Fruit.md index 92700e79e08..d65f4cb14b4 100644 --- a/samples/openapi3/client/petstore/python/docs/Fruit.md +++ b/samples/openapi3/client/petstore/python/docs/Fruit.md @@ -1,13 +1,15 @@ # Fruit +a schema that tests oneOf and includes a schema level property ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**cultivar** | **str** | | +**length_cm** | **float** | | **color** | **str** | | [optional] -**cultivar** | **str** | | [optional] **origin** | **str** | | [optional] -**length_cm** | **float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/FruitReq.md b/samples/openapi3/client/petstore/python/docs/FruitReq.md index 7ff54d6ae02..096dde57309 100644 --- a/samples/openapi3/client/petstore/python/docs/FruitReq.md +++ b/samples/openapi3/client/petstore/python/docs/FruitReq.md @@ -1,5 +1,6 @@ # FruitReq +a schema where additionalProperties is on in the composed schema and off in the oneOf object schemas also, this schem accepts null as a value ## Properties Name | Type | Description | Notes @@ -8,6 +9,7 @@ Name | Type | Description | Notes **sweet** | **bool** | | [optional] **cultivar** | **str** | | [optional] **length_cm** | **float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/GmFruit.md b/samples/openapi3/client/petstore/python/docs/GmFruit.md index f2af2abe5ce..4da4dd53ad4 100644 --- a/samples/openapi3/client/petstore/python/docs/GmFruit.md +++ b/samples/openapi3/client/petstore/python/docs/GmFruit.md @@ -4,10 +4,11 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**cultivar** | **str** | | +**length_cm** | **float** | | **color** | **str** | | [optional] -**cultivar** | **str** | | [optional] **origin** | **str** | | [optional] -**length_cm** | **float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/GrandparentAnimal.md b/samples/openapi3/client/petstore/python/docs/GrandparentAnimal.md index 15db0708bb1..a1c34037810 100644 --- a/samples/openapi3/client/petstore/python/docs/GrandparentAnimal.md +++ b/samples/openapi3/client/petstore/python/docs/GrandparentAnimal.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **pet_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md index 0e1334519a8..88bc03d4ff5 100644 --- a/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **str** | | [optional] [readonly] **foo** | **str** | | [optional] [readonly] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md index ab8b660e667..e20455fb377 100644 --- a/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md @@ -6,6 +6,7 @@ Just a string to inform instance is up and running. Make it nullable in hope to Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **nullable_message** | **str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md b/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md index f0a52bc4639..b8823d383ba 100644 --- a/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md +++ b/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **string** | [**Foo**](Foo.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/IntegerEnum.md b/samples/openapi3/client/petstore/python/docs/IntegerEnum.md index 9567a76cc2e..a5b38556bf8 100644 --- a/samples/openapi3/client/petstore/python/docs/IntegerEnum.md +++ b/samples/openapi3/client/petstore/python/docs/IntegerEnum.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **int** | | must be one of [0, 1, 2, ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/IntegerEnumOneValue.md b/samples/openapi3/client/petstore/python/docs/IntegerEnumOneValue.md index 99dcaa7a4ec..d92f3080973 100644 --- a/samples/openapi3/client/petstore/python/docs/IntegerEnumOneValue.md +++ b/samples/openapi3/client/petstore/python/docs/IntegerEnumOneValue.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **int** | | defaults to 0, must be one of [0, ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/IntegerEnumWithDefaultValue.md b/samples/openapi3/client/petstore/python/docs/IntegerEnumWithDefaultValue.md index 4b8e39d9cad..2fd432edc69 100644 --- a/samples/openapi3/client/petstore/python/docs/IntegerEnumWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python/docs/IntegerEnumWithDefaultValue.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **int** | | defaults to 0, must be one of [0, 1, 2, ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/IsoscelesTriangle.md b/samples/openapi3/client/petstore/python/docs/IsoscelesTriangle.md index e7fffa3be03..57cfa6d12ad 100644 --- a/samples/openapi3/client/petstore/python/docs/IsoscelesTriangle.md +++ b/samples/openapi3/client/petstore/python/docs/IsoscelesTriangle.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **shape_type** | **str** | | **triangle_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/List.md b/samples/openapi3/client/petstore/python/docs/List.md index 4b60956971a..13f2694de35 100644 --- a/samples/openapi3/client/petstore/python/docs/List.md +++ b/samples/openapi3/client/petstore/python/docs/List.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_123_list** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/MapTest.md b/samples/openapi3/client/petstore/python/docs/MapTest.md index 15228ee1f28..e6584f3811e 100644 --- a/samples/openapi3/client/petstore/python/docs/MapTest.md +++ b/samples/openapi3/client/petstore/python/docs/MapTest.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **map_of_enum_string** | **{str: (str,)}** | | [optional] **direct_map** | **{str: (bool,)}** | | [optional] **indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md index f489944a20a..f32c4e04134 100644 --- a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **uuid** | **str** | | [optional] **date_time** | **datetime** | | [optional] **map** | [**{str: (Animal,)}**](Animal.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Model200Response.md b/samples/openapi3/client/petstore/python/docs/Model200Response.md index c958bd4b33f..f7ef7d79acf 100644 --- a/samples/openapi3/client/petstore/python/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/python/docs/Model200Response.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | [optional] **_class** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ModelReturn.md b/samples/openapi3/client/petstore/python/docs/ModelReturn.md index 043e9d466fa..75fb39a8869 100644 --- a/samples/openapi3/client/petstore/python/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/python/docs/ModelReturn.md @@ -6,6 +6,7 @@ Model for testing reserved words Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_return** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Name.md b/samples/openapi3/client/petstore/python/docs/Name.md index 3be719cdbfb..6e58fae6d0b 100644 --- a/samples/openapi3/client/petstore/python/docs/Name.md +++ b/samples/openapi3/client/petstore/python/docs/Name.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **snake_case** | **int** | | [optional] [readonly] **_property** | **str** | | [optional] **_123_number** | **int** | | [optional] [readonly] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/NullableClass.md b/samples/openapi3/client/petstore/python/docs/NullableClass.md index 863e93ddfbb..48a27469f6c 100644 --- a/samples/openapi3/client/petstore/python/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/python/docs/NullableClass.md @@ -13,10 +13,11 @@ Name | Type | Description | Notes **array_nullable_prop** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}], none_type** | | [optional] **array_and_items_nullable_prop** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type], none_type** | | [optional] **array_items_nullable** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type]** | | [optional] +**object_nullable** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type** | | [optional] **object_nullable_prop** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}, none_type** | | [optional] **object_and_items_nullable_prop** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)}, none_type** | | [optional] **object_items_nullable** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)}** | | [optional] -**any string name** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type** | any string name can be used but the value must be the correct type | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/NumberOnly.md b/samples/openapi3/client/petstore/python/docs/NumberOnly.md index 37195c5d899..172e86163a4 100644 --- a/samples/openapi3/client/petstore/python/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/NumberOnly.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_number** | **float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/NumberWithValidations.md b/samples/openapi3/client/petstore/python/docs/NumberWithValidations.md index 119e0f67823..cc6f77c152c 100644 --- a/samples/openapi3/client/petstore/python/docs/NumberWithValidations.md +++ b/samples/openapi3/client/petstore/python/docs/NumberWithValidations.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **float** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ObjectModelWithRefProps.md b/samples/openapi3/client/petstore/python/docs/ObjectModelWithRefProps.md index 5ff4e52033d..a0d15f4bbd1 100644 --- a/samples/openapi3/client/petstore/python/docs/ObjectModelWithRefProps.md +++ b/samples/openapi3/client/petstore/python/docs/ObjectModelWithRefProps.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **my_number** | [**NumberWithValidations**](NumberWithValidations.md) | | [optional] **my_string** | **str** | | [optional] **my_boolean** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Order.md b/samples/openapi3/client/petstore/python/docs/Order.md index d29e1a381de..0423082932d 100644 --- a/samples/openapi3/client/petstore/python/docs/Order.md +++ b/samples/openapi3/client/petstore/python/docs/Order.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **ship_date** | **datetime** | | [optional] **status** | **str** | Order Status | [optional] **complete** | **bool** | | [optional] if omitted the server will use the default value of False +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Pet.md b/samples/openapi3/client/petstore/python/docs/Pet.md index ea4abdeb13d..bb6e8d344e6 100644 --- a/samples/openapi3/client/petstore/python/docs/Pet.md +++ b/samples/openapi3/client/petstore/python/docs/Pet.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **category** | [**Category**](Category.md) | | [optional] **tags** | [**[Tag]**](Tag.md) | | [optional] **status** | **str** | pet status in the store | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/QuadrilateralInterface.md b/samples/openapi3/client/petstore/python/docs/QuadrilateralInterface.md index 3b9c39d2230..05573544bd7 100644 --- a/samples/openapi3/client/petstore/python/docs/QuadrilateralInterface.md +++ b/samples/openapi3/client/petstore/python/docs/QuadrilateralInterface.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **quadrilateral_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md index 53b4c61d844..ba39ec3d04e 100644 --- a/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **str** | | [optional] [readonly] **baz** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/ShapeInterface.md b/samples/openapi3/client/petstore/python/docs/ShapeInterface.md index 4d094158fab..012d4a0cdd8 100644 --- a/samples/openapi3/client/petstore/python/docs/ShapeInterface.md +++ b/samples/openapi3/client/petstore/python/docs/ShapeInterface.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **shape_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python/docs/SpecialModelName.md index 268e1134192..4a1c86ff4de 100644 --- a/samples/openapi3/client/petstore/python/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/python/docs/SpecialModelName.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **special_property_name** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/StringEnum.md b/samples/openapi3/client/petstore/python/docs/StringEnum.md index b03f3b1e6c6..29e160a9b07 100644 --- a/samples/openapi3/client/petstore/python/docs/StringEnum.md +++ b/samples/openapi3/client/petstore/python/docs/StringEnum.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **value** | **str** | | must be one of ["placed", "approved", "delivered", "single quoted", '''multiple lines''', '''double quote with newline''', ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/StringEnumWithDefaultValue.md b/samples/openapi3/client/petstore/python/docs/StringEnumWithDefaultValue.md index 7799b93d822..700a2caf3b8 100644 --- a/samples/openapi3/client/petstore/python/docs/StringEnumWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python/docs/StringEnumWithDefaultValue.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **value** | **str** | | defaults to "placed", must be one of ["placed", "approved", "delivered", ] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Tag.md b/samples/openapi3/client/petstore/python/docs/Tag.md index 4ccac4949af..8a95090c036 100644 --- a/samples/openapi3/client/petstore/python/docs/Tag.md +++ b/samples/openapi3/client/petstore/python/docs/Tag.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **int** | | [optional] **name** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/TriangleInterface.md b/samples/openapi3/client/petstore/python/docs/TriangleInterface.md index 494c224cd31..9f8411eabdf 100644 --- a/samples/openapi3/client/petstore/python/docs/TriangleInterface.md +++ b/samples/openapi3/client/petstore/python/docs/TriangleInterface.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **triangle_type** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/User.md b/samples/openapi3/client/petstore/python/docs/User.md index a4cb117e63a..4d2da357adb 100644 --- a/samples/openapi3/client/petstore/python/docs/User.md +++ b/samples/openapi3/client/petstore/python/docs/User.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **object_with_no_declared_props_nullable** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] **any_type_prop** | **bool, date, datetime, dict, float, int, list, str, none_type** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] **any_type_prop_nullable** | **bool, date, datetime, dict, float, int, list, str, none_type** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/Whale.md b/samples/openapi3/client/petstore/python/docs/Whale.md index ea48bff6bc3..500786012ea 100644 --- a/samples/openapi3/client/petstore/python/docs/Whale.md +++ b/samples/openapi3/client/petstore/python/docs/Whale.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **class_name** | **str** | | **has_baleen** | **bool** | | [optional] **has_teeth** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/model/additional_properties_class.py index 3b526cd54e3..82aca2a9ca8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/additional_properties_class.py @@ -57,7 +57,13 @@ class AdditionalPropertiesClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -78,7 +84,7 @@ class AdditionalPropertiesClass(ModelNormal): 'map_with_undeclared_properties_anytype_1': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 'map_with_undeclared_properties_anytype_2': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 'map_with_undeclared_properties_anytype_3': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 - 'empty_map': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501 + 'empty_map': (dict,), # noqa: E501 'map_with_undeclared_properties_string': ({str: (str,)},), # noqa: E501 } @@ -150,7 +156,7 @@ class AdditionalPropertiesClass(ModelNormal): map_with_undeclared_properties_anytype_1 ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 map_with_undeclared_properties_anytype_2 ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 map_with_undeclared_properties_anytype_3 ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 - empty_map (bool, date, datetime, dict, float, int, list, str): an object with no declared properties and no undeclared properties, hence it's an empty map.. [optional] # noqa: E501 + empty_map (dict): an object with no declared properties and no undeclared properties, hence it's an empty map.. [optional] # noqa: E501 map_with_undeclared_properties_string ({str: (str,)}): [optional] # noqa: E501 """ diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/animal.py b/samples/openapi3/client/petstore/python/petstore_api/model/animal.py index a3d48b6ea97..c53b1e1ad28 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/animal.py @@ -63,7 +63,14 @@ class Animal(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/animal_farm.py b/samples/openapi3/client/petstore/python/petstore_api/model/animal_farm.py index 838b18a1297..fb58224ebd4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/animal_farm.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/animal_farm.py @@ -57,7 +57,14 @@ class AnimalFarm(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/api_response.py b/samples/openapi3/client/petstore/python/petstore_api/model/api_response.py index 01e2175b800..53adb5aba12 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/api_response.py @@ -57,7 +57,13 @@ class ApiResponse(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/apple.py b/samples/openapi3/client/petstore/python/petstore_api/model/apple.py index 29d34a1efe8..4068d2488e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/apple.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/apple.py @@ -68,7 +68,13 @@ class Apple(ModelNormal): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = True @@ -109,9 +115,12 @@ class Apple(ModelNormal): ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, cultivar, *args, **kwargs): # noqa: E501 """Apple - a model defined in OpenAPI + Args: + cultivar (str): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -143,7 +152,6 @@ class Apple(ModelNormal): Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - cultivar (str): [optional] # noqa: E501 origin (str): [optional] # noqa: E501 """ @@ -170,6 +178,7 @@ class Apple(ModelNormal): self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.cultivar = cultivar for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py index 008b74dd42a..8b6a2c42d0e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_array_of_number_only.py @@ -57,7 +57,13 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_enums.py b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_enums.py index a3dc283969a..8d9962152ed 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_enums.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_enums.py @@ -57,7 +57,14 @@ class ArrayOfEnums(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_number_only.py index f2e080bc258..7b754dc283e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/array_of_number_only.py @@ -57,7 +57,13 @@ class ArrayOfNumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/model/array_test.py index ac42b07b93c..9691a1e6037 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/array_test.py @@ -61,7 +61,14 @@ class ArrayTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/banana.py b/samples/openapi3/client/petstore/python/petstore_api/model/banana.py index 513bd6bf06b..24ad257e6d2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/banana.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/banana.py @@ -57,7 +57,13 @@ class Banana(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -96,9 +102,12 @@ class Banana(ModelNormal): ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, length_cm, *args, **kwargs): # noqa: E501 """Banana - a model defined in OpenAPI + Args: + length_cm (float): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -130,7 +139,6 @@ class Banana(ModelNormal): Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - length_cm (float): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -156,6 +164,7 @@ class Banana(ModelNormal): self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.length_cm = length_cm for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/model/basque_pig.py index 603f7761867..25b336460bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/basque_pig.py @@ -57,7 +57,13 @@ class BasquePig(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/model/capitalization.py index 710c17e51a5..6d939535cee 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/capitalization.py @@ -57,7 +57,13 @@ class Capitalization(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/cat.py b/samples/openapi3/client/petstore/python/petstore_api/model/cat.py index 1d62177c6c2..eeea79359fc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/cat.py @@ -27,10 +27,8 @@ from petstore_api.model_utils import ( # noqa: F401 ) def lazy_import(): - from petstore_api.model.address import Address from petstore_api.model.animal import Animal from petstore_api.model.cat_all_of import CatAllOf - globals()['Address'] = Address globals()['Animal'] = Animal globals()['CatAllOf'] = CatAllOf @@ -120,13 +118,11 @@ class Cat(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Cat - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -191,26 +187,18 @@ class Cat(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) @@ -229,7 +217,6 @@ class Cat(ModelComposed): 'anyOf': [ ], 'allOf': [ - Address, Animal, CatAllOf, ], diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/cat_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/model/cat_all_of.py index 50b046510df..7efba680b4d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/cat_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/cat_all_of.py @@ -57,7 +57,13 @@ class CatAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/category.py b/samples/openapi3/client/petstore/python/petstore_api/model/category.py index ed167471d35..4936b4f0e44 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/category.py @@ -57,7 +57,13 @@ class Category(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/child_cat.py b/samples/openapi3/client/petstore/python/petstore_api/model/child_cat.py index e1869c917cd..d054cb7a97a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/child_cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/child_cat.py @@ -116,13 +116,11 @@ class ChildCat(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ChildCat - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -186,26 +184,18 @@ class ChildCat(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/child_cat_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/model/child_cat_all_of.py index f0f1a1ae6bd..3d732d085fb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/child_cat_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/child_cat_all_of.py @@ -57,7 +57,13 @@ class ChildCatAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/model/class_model.py index 18c16f89f90..9e65a937365 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/class_model.py @@ -57,7 +57,13 @@ class ClassModel(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/client.py b/samples/openapi3/client/petstore/python/petstore_api/model/client.py index da615c54773..6218de1e19e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/client.py @@ -57,7 +57,13 @@ class Client(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/complex_quadrilateral.py b/samples/openapi3/client/petstore/python/petstore_api/model/complex_quadrilateral.py index 56853f5f34f..e461673adbd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/complex_quadrilateral.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/complex_quadrilateral.py @@ -113,14 +113,12 @@ class ComplexQuadrilateral(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, quadrilateral_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ComplexQuadrilateral - a model defined in OpenAPI - Args: + Keyword Args: shape_type (str): quadrilateral_type (str): - - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -183,27 +181,18 @@ class ComplexQuadrilateral(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - 'quadrilateral_type': quadrilateral_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py b/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py index 4a1129432f5..299c866cf8f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py @@ -181,25 +181,18 @@ class ComposedOneOfNumberWithValidations(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/composed_schema_with_props_and_no_add_props.py b/samples/openapi3/client/petstore/python/petstore_api/model/composed_schema_with_props_and_no_add_props.py new file mode 100644 index 00000000000..518f4774b55 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/composed_schema_with_props_and_no_add_props.py @@ -0,0 +1,212 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.tag import Tag + globals()['Tag'] = Tag + + +class ComposedSchemaWithPropsAndNoAddProps(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'color': (str,), # noqa: E501 + 'id': (int,), # noqa: E501 + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'color': 'color', # noqa: E501 + 'id': 'id', # noqa: E501 + 'name': 'name', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """ComposedSchemaWithPropsAndNoAddProps - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + color (str): [optional] # noqa: E501 + id (int): [optional] # noqa: E501 + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + Tag, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/model/danish_pig.py index 5a6e424a4ec..82215915e84 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/danish_pig.py @@ -57,7 +57,13 @@ class DanishPig(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/dog.py b/samples/openapi3/client/petstore/python/petstore_api/model/dog.py index 8bf6d8fd3ad..3452f0d040a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/dog.py @@ -118,13 +118,11 @@ class Dog(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Dog - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -189,26 +187,18 @@ class Dog(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/dog_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/model/dog_all_of.py index b7b2e7db66d..962903d3a38 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/dog_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/dog_all_of.py @@ -57,7 +57,13 @@ class DogAllOf(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/model/enum_arrays.py index 43ebac57de3..db56838d7e4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/enum_arrays.py @@ -65,7 +65,13 @@ class EnumArrays(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python/petstore_api/model/enum_class.py index 14188ca31d2..63be703c38e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/enum_class.py @@ -58,7 +58,13 @@ class EnumClass(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/model/enum_test.py index c0284b371a9..23ddbcf9a2c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/enum_test.py @@ -89,7 +89,14 @@ class EnumTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/equilateral_triangle.py b/samples/openapi3/client/petstore/python/petstore_api/model/equilateral_triangle.py index a536701d701..e5e4104bd02 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/equilateral_triangle.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/equilateral_triangle.py @@ -113,14 +113,12 @@ class EquilateralTriangle(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, triangle_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """EquilateralTriangle - a model defined in OpenAPI - Args: + Keyword Args: shape_type (str): triangle_type (str): - - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -183,27 +181,18 @@ class EquilateralTriangle(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - 'triangle_type': triangle_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/file.py b/samples/openapi3/client/petstore/python/petstore_api/model/file.py index a38cccacc6a..137d0026324 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/file.py @@ -57,7 +57,13 @@ class File(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/model/file_schema_test_class.py index b8c519ed9c7..3722125ae48 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/file_schema_test_class.py @@ -61,7 +61,14 @@ class FileSchemaTestClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/foo.py b/samples/openapi3/client/petstore/python/petstore_api/model/foo.py index ebbb09adf91..7c319dc9995 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/foo.py @@ -57,7 +57,13 @@ class Foo(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/model/format_test.py index b232da04b45..cce7f7f0981 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/format_test.py @@ -100,7 +100,13 @@ class FormatTest(ModelNormal): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/fruit.py b/samples/openapi3/client/petstore/python/petstore_api/model/fruit.py index 15ea987edf5..c7283f99d0c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/fruit.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/fruit.py @@ -74,7 +74,14 @@ class Fruit(ModelComposed): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -90,10 +97,10 @@ class Fruit(ModelComposed): """ lazy_import() return { - 'color': (str,), # noqa: E501 'cultivar': (str,), # noqa: E501 - 'origin': (str,), # noqa: E501 'length_cm': (float,), # noqa: E501 + 'color': (str,), # noqa: E501 + 'origin': (str,), # noqa: E501 } @cached_property @@ -102,10 +109,10 @@ class Fruit(ModelComposed): attribute_map = { - 'color': 'color', # noqa: E501 'cultivar': 'cultivar', # noqa: E501 - 'origin': 'origin', # noqa: E501 'length_cm': 'lengthCm', # noqa: E501 + 'color': 'color', # noqa: E501 + 'origin': 'origin', # noqa: E501 } required_properties = set([ @@ -125,6 +132,8 @@ class Fruit(ModelComposed): """Fruit - a model defined in OpenAPI Keyword Args: + cultivar (str): + length_cm (float): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -156,9 +165,7 @@ class Fruit(ModelComposed): through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] # noqa: E501 - cultivar (str): [optional] # noqa: E501 origin (str): [optional] # noqa: E501 - length_cm (float): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -191,25 +198,18 @@ class Fruit(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/fruit_req.py b/samples/openapi3/client/petstore/python/petstore_api/model/fruit_req.py index 13c4d6424a5..519aa6d20eb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/fruit_req.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/fruit_req.py @@ -63,7 +63,14 @@ class FruitReq(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -180,25 +187,18 @@ class FruitReq(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/gm_fruit.py b/samples/openapi3/client/petstore/python/petstore_api/model/gm_fruit.py index f3ad29beb4c..dc9299c2a1b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/gm_fruit.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/gm_fruit.py @@ -74,7 +74,14 @@ class GmFruit(ModelComposed): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -90,10 +97,10 @@ class GmFruit(ModelComposed): """ lazy_import() return { - 'color': (str,), # noqa: E501 'cultivar': (str,), # noqa: E501 - 'origin': (str,), # noqa: E501 'length_cm': (float,), # noqa: E501 + 'color': (str,), # noqa: E501 + 'origin': (str,), # noqa: E501 } @cached_property @@ -102,10 +109,10 @@ class GmFruit(ModelComposed): attribute_map = { - 'color': 'color', # noqa: E501 'cultivar': 'cultivar', # noqa: E501 - 'origin': 'origin', # noqa: E501 'length_cm': 'lengthCm', # noqa: E501 + 'color': 'color', # noqa: E501 + 'origin': 'origin', # noqa: E501 } required_properties = set([ @@ -125,6 +132,8 @@ class GmFruit(ModelComposed): """GmFruit - a model defined in OpenAPI Keyword Args: + cultivar (str): + length_cm (float): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -156,9 +165,7 @@ class GmFruit(ModelComposed): through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] # noqa: E501 - cultivar (str): [optional] # noqa: E501 origin (str): [optional] # noqa: E501 - length_cm (float): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -191,25 +198,18 @@ class GmFruit(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/grandparent_animal.py b/samples/openapi3/client/petstore/python/petstore_api/model/grandparent_animal.py index f7c417562ec..70523affd89 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/grandparent_animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/grandparent_animal.py @@ -63,7 +63,14 @@ class GrandparentAnimal(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/model/has_only_read_only.py index c94781ae2c4..4ea0bb08721 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/has_only_read_only.py @@ -57,7 +57,13 @@ class HasOnlyReadOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/model/health_check_result.py index 3c0cd37dfad..356ddea3cb1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/health_check_result.py @@ -57,7 +57,13 @@ class HealthCheckResult(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/inline_response_default.py b/samples/openapi3/client/petstore/python/petstore_api/model/inline_response_default.py index 8e814cf4383..cb7b9985ea8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/inline_response_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/inline_response_default.py @@ -61,7 +61,14 @@ class InlineResponseDefault(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum.py b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum.py index a01fc614922..a31cd7c5695 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum.py @@ -58,7 +58,13 @@ class IntegerEnum(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_one_value.py b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_one_value.py index 0d69cd535b3..f8fc86bfba7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_one_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_one_value.py @@ -56,7 +56,13 @@ class IntegerEnumOneValue(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_with_default_value.py index 958b2ad2e39..3c56da865f6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_with_default_value.py @@ -58,7 +58,13 @@ class IntegerEnumWithDefaultValue(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/isosceles_triangle.py b/samples/openapi3/client/petstore/python/petstore_api/model/isosceles_triangle.py index 27197f5a235..b1f64bcb0db 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/isosceles_triangle.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/isosceles_triangle.py @@ -63,7 +63,14 @@ class IsoscelesTriangle(ModelComposed): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -106,14 +113,12 @@ class IsoscelesTriangle(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, triangle_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """IsoscelesTriangle - a model defined in OpenAPI - Args: + Keyword Args: shape_type (str): triangle_type (str): - - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -176,27 +181,18 @@ class IsoscelesTriangle(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - 'triangle_type': triangle_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/list.py b/samples/openapi3/client/petstore/python/petstore_api/model/list.py index 09c762d6a79..11b46f10b56 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/list.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/list.py @@ -57,7 +57,13 @@ class List(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/mammal.py b/samples/openapi3/client/petstore/python/petstore_api/model/mammal.py index 067adf79350..234933fe1a8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/mammal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/mammal.py @@ -131,13 +131,11 @@ class Mammal(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Mammal - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -203,26 +201,18 @@ class Mammal(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/model/map_test.py index 169fb9d88ee..a5418b39e73 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/map_test.py @@ -65,7 +65,14 @@ class MapTest(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py index 01df80d9d62..67b3f79d9e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/mixed_properties_and_additional_properties_class.py @@ -61,7 +61,14 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/model/model200_response.py index 46b155b6523..056f4c56ad3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/model200_response.py @@ -57,7 +57,13 @@ class Model200Response(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/model/model_return.py index 377b3507a8b..5f34582cdb4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/model_return.py @@ -57,7 +57,13 @@ class ModelReturn(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/name.py b/samples/openapi3/client/petstore/python/petstore_api/model/name.py index 1432e185ad6..06b387ce9bf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/name.py @@ -57,7 +57,13 @@ class Name(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/model/nullable_class.py index a117dfa6916..f2c2cb7642e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/nullable_class.py @@ -63,7 +63,7 @@ class NullableClass(ModelNormal): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type,) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -87,6 +87,7 @@ class NullableClass(ModelNormal): 'array_nullable_prop': ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}], none_type,), # noqa: E501 'array_and_items_nullable_prop': ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type], none_type,), # noqa: E501 'array_items_nullable': ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type],), # noqa: E501 + 'object_nullable': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type,), # noqa: E501 'object_nullable_prop': ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}, none_type,), # noqa: E501 'object_and_items_nullable_prop': ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)}, none_type,), # noqa: E501 'object_items_nullable': ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)},), # noqa: E501 @@ -107,6 +108,7 @@ class NullableClass(ModelNormal): 'array_nullable_prop': 'array_nullable_prop', # noqa: E501 'array_and_items_nullable_prop': 'array_and_items_nullable_prop', # noqa: E501 'array_items_nullable': 'array_items_nullable', # noqa: E501 + 'object_nullable': 'object_nullable', # noqa: E501 'object_nullable_prop': 'object_nullable_prop', # noqa: E501 'object_and_items_nullable_prop': 'object_and_items_nullable_prop', # noqa: E501 'object_items_nullable': 'object_items_nullable', # noqa: E501 @@ -167,6 +169,7 @@ class NullableClass(ModelNormal): array_nullable_prop ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}], none_type): [optional] # noqa: E501 array_and_items_nullable_prop ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type], none_type): [optional] # noqa: E501 array_items_nullable ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type]): [optional] # noqa: E501 + object_nullable ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type): [optional] # noqa: E501 object_nullable_prop ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}, none_type): [optional] # noqa: E501 object_and_items_nullable_prop ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)}, none_type): [optional] # noqa: E501 object_items_nullable ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type)}): [optional] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/nullable_shape.py b/samples/openapi3/client/petstore/python/petstore_api/model/nullable_shape.py index fcd20ddfbc1..a2cf17e3e7b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/nullable_shape.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/nullable_shape.py @@ -121,13 +121,11 @@ class NullableShape(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """NullableShape - a model defined in OpenAPI - Args: - shape_type (str): - Keyword Args: + shape_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -192,26 +190,18 @@ class NullableShape(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/model/number_only.py index d4892dbede5..cb2c9e2ad52 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/number_only.py @@ -57,7 +57,13 @@ class NumberOnly(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/number_with_validations.py b/samples/openapi3/client/petstore/python/petstore_api/model/number_with_validations.py index ffa5e9cf462..a3b2746c22b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/number_with_validations.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/number_with_validations.py @@ -57,7 +57,13 @@ class NumberWithValidations(ModelSimple): }, } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/object_model_with_ref_props.py b/samples/openapi3/client/petstore/python/petstore_api/model/object_model_with_ref_props.py index b1dc4bf82e2..7256f67a8d6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/object_model_with_ref_props.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/object_model_with_ref_props.py @@ -61,7 +61,14 @@ class ObjectModelWithRefProps(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/order.py b/samples/openapi3/client/petstore/python/petstore_api/model/order.py index b42f066848a..48207e4560e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/order.py @@ -62,7 +62,13 @@ class Order(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/parent_pet.py b/samples/openapi3/client/petstore/python/petstore_api/model/parent_pet.py index 16099236da3..bda9c277996 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/parent_pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/parent_pet.py @@ -116,13 +116,11 @@ class ParentPet(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, pet_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ParentPet - a model defined in OpenAPI - Args: - pet_type (str): - Keyword Args: + pet_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -185,26 +183,18 @@ class ParentPet(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'pet_type': pet_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/pet.py b/samples/openapi3/client/petstore/python/petstore_api/model/pet.py index e9f1e30a319..b0c8b08607d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/pet.py @@ -68,7 +68,14 @@ class Pet(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/pig.py b/samples/openapi3/client/petstore/python/petstore_api/model/pig.py index 4a6f200f6ff..21f61c65de0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/pig.py @@ -117,13 +117,11 @@ class Pig(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, class_name, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Pig - a model defined in OpenAPI - Args: - class_name (str): - Keyword Args: + class_name (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -186,26 +184,18 @@ class Pig(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'class_name': class_name, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral.py b/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral.py index 4e28ac0d238..d15d37cdbca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral.py @@ -119,13 +119,11 @@ class Quadrilateral(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, quadrilateral_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Quadrilateral - a model defined in OpenAPI - Args: - quadrilateral_type (str): - Keyword Args: + quadrilateral_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -189,26 +187,18 @@ class Quadrilateral(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'quadrilateral_type': quadrilateral_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral_interface.py b/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral_interface.py index 124d9128bc5..872608885ac 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral_interface.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/quadrilateral_interface.py @@ -57,7 +57,13 @@ class QuadrilateralInterface(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/model/read_only_first.py index 5c68eab91ea..0302bf96a7e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/read_only_first.py @@ -57,7 +57,13 @@ class ReadOnlyFirst(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/scalene_triangle.py b/samples/openapi3/client/petstore/python/petstore_api/model/scalene_triangle.py index 1e3893627da..86fc0a4f495 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/scalene_triangle.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/scalene_triangle.py @@ -113,14 +113,12 @@ class ScaleneTriangle(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, triangle_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ScaleneTriangle - a model defined in OpenAPI - Args: + Keyword Args: shape_type (str): triangle_type (str): - - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -183,27 +181,18 @@ class ScaleneTriangle(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - 'triangle_type': triangle_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/shape.py b/samples/openapi3/client/petstore/python/petstore_api/model/shape.py index f5e3c142b91..763a7aa362b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/shape.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/shape.py @@ -121,13 +121,11 @@ class Shape(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Shape - a model defined in OpenAPI - Args: - shape_type (str): - Keyword Args: + shape_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -192,26 +190,18 @@ class Shape(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/shape_interface.py b/samples/openapi3/client/petstore/python/petstore_api/model/shape_interface.py index 8a3c52088be..b8ab31fc31c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/shape_interface.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/shape_interface.py @@ -57,7 +57,13 @@ class ShapeInterface(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/shape_or_null.py b/samples/openapi3/client/petstore/python/petstore_api/model/shape_or_null.py index 480fa5bd5d6..403449e0c9c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/shape_or_null.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/shape_or_null.py @@ -121,13 +121,11 @@ class ShapeOrNull(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """ShapeOrNull - a model defined in OpenAPI - Args: - shape_type (str): - Keyword Args: + shape_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -192,26 +190,18 @@ class ShapeOrNull(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/simple_quadrilateral.py b/samples/openapi3/client/petstore/python/petstore_api/model/simple_quadrilateral.py index f2f0a61acbd..d68f1d3b5cb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/simple_quadrilateral.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/simple_quadrilateral.py @@ -113,14 +113,12 @@ class SimpleQuadrilateral(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, shape_type, quadrilateral_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """SimpleQuadrilateral - a model defined in OpenAPI - Args: + Keyword Args: shape_type (str): quadrilateral_type (str): - - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -183,27 +181,18 @@ class SimpleQuadrilateral(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'shape_type': shape_type, - 'quadrilateral_type': quadrilateral_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/some_object.py b/samples/openapi3/client/petstore/python/petstore_api/model/some_object.py index 683d1794293..72687c02ab6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/some_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/some_object.py @@ -173,25 +173,18 @@ class SomeObject(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/model/special_model_name.py index 823e7759663..cfaedbc7881 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/special_model_name.py @@ -57,7 +57,13 @@ class SpecialModelName(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python/petstore_api/model/string_enum.py index a6d2fbee08f..1e48fdecbf4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/string_enum.py @@ -64,7 +64,13 @@ lines''', validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/model/string_enum_with_default_value.py index 4dfc426446c..1417d0ff0fc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/string_enum_with_default_value.py @@ -58,7 +58,13 @@ class StringEnumWithDefaultValue(ModelSimple): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/tag.py b/samples/openapi3/client/petstore/python/petstore_api/model/tag.py index e5fc749d514..0e7427effa6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/tag.py @@ -57,7 +57,13 @@ class Tag(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/triangle.py b/samples/openapi3/client/petstore/python/petstore_api/model/triangle.py index 83d6e52e886..b1112e24892 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/triangle.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/triangle.py @@ -122,13 +122,11 @@ class Triangle(ModelComposed): ]) @convert_js_args_to_python_args - def __init__(self, triangle_type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Triangle - a model defined in OpenAPI - Args: - triangle_type (str): - Keyword Args: + triangle_type (str): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -192,26 +190,18 @@ class Triangle(ModelComposed): '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { - 'triangle_type': triangle_type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/triangle_interface.py b/samples/openapi3/client/petstore/python/petstore_api/model/triangle_interface.py index c54bd081172..f31e3dba135 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/triangle_interface.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/triangle_interface.py @@ -57,7 +57,13 @@ class TriangleInterface(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/user.py b/samples/openapi3/client/petstore/python/petstore_api/model/user.py index 7613ac7dc26..2271e3e37e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/user.py @@ -57,7 +57,13 @@ class User(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/whale.py b/samples/openapi3/client/petstore/python/petstore_api/model/whale.py index e6400ea34fc..c3e1c40b4e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/whale.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/whale.py @@ -57,7 +57,13 @@ class Whale(ModelNormal): validations = { } - additional_properties_type = None + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False diff --git a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py index ae554710670..b6d5934170a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py @@ -434,27 +434,43 @@ class ModelComposed(OpenApiModel): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -464,13 +480,12 @@ class ModelComposed(OpenApiModel): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1573,8 +1588,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1582,20 +1602,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1655,31 +1663,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1736,24 +1722,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1766,47 +1736,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1850,36 +1807,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 4941dc7de6e..465f610d6d4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -34,6 +34,7 @@ from petstore_api.model.class_model import ClassModel from petstore_api.model.client import Client from petstore_api.model.complex_quadrilateral import ComplexQuadrilateral from petstore_api.model.composed_one_of_number_with_validations import ComposedOneOfNumberWithValidations +from petstore_api.model.composed_schema_with_props_and_no_add_props import ComposedSchemaWithPropsAndNoAddProps from petstore_api.model.danish_pig import DanishPig from petstore_api.model.dog import Dog from petstore_api.model.dog_all_of import DogAllOf diff --git a/samples/openapi3/client/petstore/python/pom.xml b/samples/openapi3/client/petstore/python/pom.xml index c2364c74482..e7d7d9caf13 100644 --- a/samples/openapi3/client/petstore/python/pom.xml +++ b/samples/openapi3/client/petstore/python/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.openapitools - PythonExperimentalOAS3PetstoreTests + PythonOAS3PetstoreTests pom 1.0-SNAPSHOT - Python-Experimental OpenAPI3 Petstore Client + Python OpenAPI3 Petstore Client diff --git a/samples/openapi3/client/petstore/python/test/test_composed_schema_with_props_and_no_add_props.py b/samples/openapi3/client/petstore/python/test/test_composed_schema_with_props_and_no_add_props.py new file mode 100644 index 00000000000..7e7ac901ca6 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_composed_schema_with_props_and_no_add_props.py @@ -0,0 +1,37 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.tag import Tag +globals()['Tag'] = Tag +from petstore_api.model.composed_schema_with_props_and_no_add_props import ComposedSchemaWithPropsAndNoAddProps + + +class TestComposedSchemaWithPropsAndNoAddProps(unittest.TestCase): + """ComposedSchemaWithPropsAndNoAddProps unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testComposedSchemaWithPropsAndNoAddProps(self): + """Test ComposedSchemaWithPropsAndNoAddProps""" + # FIXME: construct object with mandatory attributes with example values + # model = ComposedSchemaWithPropsAndNoAddProps() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_composed_schema_with_props_and_no_add_props.py b/samples/openapi3/client/petstore/python/tests_manual/test_composed_schema_with_props_and_no_add_props.py new file mode 100644 index 00000000000..d219a4e4b8a --- /dev/null +++ b/samples/openapi3/client/petstore/python/tests_manual/test_composed_schema_with_props_and_no_add_props.py @@ -0,0 +1,45 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.tag import Tag +globals()['Tag'] = Tag +from petstore_api.model.composed_schema_with_props_and_no_add_props import ComposedSchemaWithPropsAndNoAddProps + + +class TestComposedSchemaWithPropsAndNoAddProps(unittest.TestCase): + """ComposedSchemaWithPropsAndNoAddProps unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testComposedSchemaWithPropsAndNoAddProps(self): + """Test ComposedSchemaWithPropsAndNoAddProps""" + + inst = ComposedSchemaWithPropsAndNoAddProps(color='red') + + # ComposedSchemaWithPropsAndNoAddProps should only allow in the color property + # once https://github.com/OpenAPITools/openapi-generator/pull/8816 lands + # this will no longer work + # TODO update the test then + inst = ComposedSchemaWithPropsAndNoAddProps(color='red', id=1, name='foo') + + with self.assertRaises(petstore_api.ApiAttributeError): + inst = ComposedSchemaWithPropsAndNoAddProps(color='red', id=1, name='foo', additional=5) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_deserialization.py b/samples/openapi3/client/petstore/python/tests_manual/test_deserialization.py index 37e0943273a..93538160f9a 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_deserialization.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_deserialization.py @@ -118,12 +118,7 @@ class DeserializationTests(unittest.TestCase): ) assert isinstance(inst, apple.Apple) - inst = apple.Apple( - origin="cHiLe" - ) - assert isinstance(inst, apple.Apple) - - # Test with invalid regex pattern. + # Test with invalid regex pattern in cultivar err_msg = ("Invalid value for `{}`, must match regular expression `{}`$") with self.assertRaisesRegex( petstore_api.ApiValueError, @@ -133,12 +128,14 @@ class DeserializationTests(unittest.TestCase): cultivar="!@#%@$#Akane" ) + # Test with invalid regex pattern in origin err_msg = ("Invalid value for `{}`, must match regular expression `{}` with flags") with self.assertRaisesRegex( petstore_api.ApiValueError, err_msg.format("origin", "[^`]*") ): inst = apple.Apple( + cultivar="Akane", origin="!@#%@$#Chile" ) diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_discard_unknown_properties.py b/samples/openapi3/client/petstore/python/tests_manual/test_discard_unknown_properties.py index d8b71e44353..ed1ca736d4b 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_discard_unknown_properties.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_discard_unknown_properties.py @@ -16,7 +16,7 @@ import re import unittest import petstore_api -from petstore_api.model import cat, dog, isosceles_triangle, banana_req +from petstore_api.model import cat, dog, isosceles_triangle, banana_req, fruit_req from petstore_api import Configuration, signing from petstore_api.model_utils import ( @@ -54,17 +54,17 @@ class DiscardUnknownPropertiesTests(unittest.TestCase): 'Exception message: {0}'.format(str(cm.exception))) - def test_deserialize_isosceles_triangle_do_not_discard_unknown_properties(self): + def test_deserialize_fruit_req_do_not_discard_unknown_properties(self): """ - deserialize IsoscelesTriangle with unknown properties. + deserialize FruitReq with unknown properties. Strict validation is enabled. Composed schema scenario. """ config = Configuration(discard_unknown_keys=False) api_client = petstore_api.ApiClient(config) data = { - 'shape_type': 'Triangle', - 'triangle_type': 'EquilateralTriangle', + 'lengthCm': 21.3, + 'sweet': False, # Below is an unknown property not explicitly declared in the OpenAPI document. # It should not be in the payload because additional properties (undeclared) are # not allowed in the schema (additionalProperties: false). @@ -74,10 +74,29 @@ class DiscardUnknownPropertiesTests(unittest.TestCase): # Deserializing with strict validation raises an exception because the 'unknown_property' # is undeclared. - with self.assertRaises(petstore_api.ApiValueError) as cm: - deserialized = api_client.deserialize(response, ((isosceles_triangle.IsoscelesTriangle),), True) - self.assertTrue(re.match('.*Not all inputs were used.*unknown_property.*', str(cm.exception)), - 'Exception message: {0}'.format(str(cm.exception))) + with self.assertRaisesRegex(petstore_api.ApiValueError, "Invalid inputs given to generate an instance of FruitReq. None of the oneOf schemas matched the input data."): + deserialized = api_client.deserialize(response, ((fruit_req.FruitReq),), True) + + + def test_deserialize_fruit_req_discard_unknown_properties(self): + """ + deserialize FruitReq with unknown properties. + Strict validation is enabled. + Composed schema scenario. + """ + config = Configuration(discard_unknown_keys=True) + api_client = petstore_api.ApiClient(config) + data = { + 'lengthCm': 21.3, + 'sweet': False, + # Below is an unknown property not explicitly declared in the OpenAPI document. + # It should not be in the payload because additional properties (undeclared) are + # not allowed in BananaReq + 'unknown_property': 'a-value' + } + response = MockResponse(data=json.dumps(data)) + deserialized = api_client.deserialize(response, ((fruit_req.FruitReq),), True) + self.assertNotIn("unknown_property", deserialized.to_dict().keys()) def test_deserialize_banana_req_discard_unknown_properties(self): @@ -145,13 +164,10 @@ class DiscardUnknownPropertiesTests(unittest.TestCase): # Below are additional (undeclared) properties. "my_additional_property": 123, } - # The 'my_additional_property' is undeclared, but 'Cat' has a 'Address' type through - # the allOf: [ $ref: '#/components/schemas/Address' ]. + # The 'my_additional_property' is undeclared response = MockResponse(data=json.dumps(data)) deserialized = api_client.deserialize(response, ((cat.Cat),), True) self.assertTrue(isinstance(deserialized, cat.Cat)) - # Check the 'unknown_property' and 'more-unknown' properties are not present in the - # output. - self.assertIn("declawed", deserialized.to_dict().keys()) + # Check the 'my_additional_property' is present self.assertIn("my_additional_property", deserialized.to_dict().keys()) diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py b/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py index a60fdb9f6be..f95c07755f8 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py @@ -14,56 +14,70 @@ import sys import unittest import petstore_api -try: - from petstore_api.model import apple -except ImportError: - apple = sys.modules[ - 'petstore_api.model.apple'] -try: - from petstore_api.model import banana -except ImportError: - banana = sys.modules[ - 'petstore_api.model.banana'] +from petstore_api.model import apple +from petstore_api.model import banana from petstore_api.model.fruit import Fruit class TestFruit(unittest.TestCase): """Fruit unit test stubs""" + length_cm = 20.3 + color = 'yellow' + + def setUp(self): pass def tearDown(self): pass - def testFruit(self): - """Test Fruit""" + def test_fruit_with_additional_props(self): + # including extra parameters works because the oneOf models include additionalProperties + some_value = 'some_value' + some_fruit = Fruit( + color=self.color, + length_cm=self.length_cm, + unknown_property=some_value + ) + assert some_fruit['unknown_property'] == some_value + + def test_fruit_assigning_additional_props_in_client(self): + # setting a value that doesn't exist works because additional_properties_type allows any type + other_fruit = Fruit(length_cm=self.length_cm, color=self.color) + blah = 'blah' + other_fruit['a'] = blah + assert other_fruit.a == blah + + # with setattr + setattr(other_fruit, 'b', blah) + assert other_fruit.b == blah - # make an instance of Fruit, a composed schema oneOf model - # banana test - length_cm = 20.3 - color = 'yellow' - fruit = Fruit(length_cm=length_cm, color=color) - # check its properties - self.assertEqual(fruit.length_cm, length_cm) - self.assertEqual(fruit['length_cm'], length_cm) - self.assertEqual(fruit.get('length_cm'), length_cm) - self.assertEqual(getattr(fruit, 'length_cm'), length_cm) - self.assertEqual(fruit.color, color) - self.assertEqual(fruit['color'], color) - self.assertEqual(getattr(fruit, 'color'), color) - # check the dict representation self.assertEqual( - fruit.to_dict(), + other_fruit.to_dict(), { - 'length_cm': length_cm, - 'color': color + 'a': 'blah', + 'b': 'blah', + 'length_cm': self.length_cm, + 'color': self.color } ) - # setting a value that doesn't exist raises an exception + + def test_fruit_access_errors(self): + fruit = Fruit(length_cm=self.length_cm, color=self.color) + + # getting a value that doesn't exist raises an exception # with a key with self.assertRaises(AttributeError): - fruit['invalid_variable'] = 'some value' + invalid_variable = fruit['cultivar'] + + # Per Python doc, if the named attribute does not exist, + # default is returned if provided, otherwise AttributeError is raised. + with self.assertRaises(AttributeError): + getattr(fruit, 'cultivar') + + def test_fruit_attribute_access(self): + fruit = Fruit(length_cm=self.length_cm, color=self.color) # Assert that we can call the builtin hasattr() function. # hasattr should return False for non-existent attribute. @@ -74,14 +88,6 @@ class TestFruit(unittest.TestCase): # hasattr should return True for existent attribute. self.assertTrue(hasattr(fruit, 'color')) - # with setattr - with self.assertRaises(AttributeError): - setattr(fruit, 'invalid_variable', 'some value') - - # getting a value that doesn't exist raises an exception - # with a key - with self.assertRaises(AttributeError): - invalid_variable = fruit['cultivar'] # with getattr # Per Python doc, if the named attribute does not exist, # default is returned if provided. @@ -89,10 +95,28 @@ class TestFruit(unittest.TestCase): self.assertEqual(fruit.get('cultivar'), None) self.assertEqual(fruit.get('cultivar', 'some value'), 'some value') - # Per Python doc, if the named attribute does not exist, - # default is returned if provided, otherwise AttributeError is raised. - with self.assertRaises(AttributeError): - getattr(fruit, 'cultivar') + def test_banana_fruit(self): + """Test Fruit""" + + # make an instance of Fruit, a composed schema oneOf model + # banana test + fruit = Fruit(length_cm=self.length_cm, color=self.color) + # check its properties + self.assertEqual(fruit.length_cm, self.length_cm) + self.assertEqual(fruit['length_cm'], self.length_cm) + self.assertEqual(fruit.get('length_cm'), self.length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), self.length_cm) + self.assertEqual(fruit.color, self.color) + self.assertEqual(fruit['color'], self.color) + self.assertEqual(getattr(fruit, 'color'), self.color) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'length_cm': self.length_cm, + 'color': self.color + } + ) # make sure that the ModelComposed class properties are correct # model._composed_schemas stores the anyOf/allOf/oneOf info @@ -109,6 +133,7 @@ class TestFruit(unittest.TestCase): ) # model._composed_instances is a list of the instances that were # made from the anyOf/allOf/OneOf classes in model._composed_schemas + self.assertEqual(len(fruit._composed_instances), 1) for composed_instance in fruit._composed_instances: if composed_instance.__class__ == banana.Banana: banana_instance = composed_instance @@ -118,19 +143,16 @@ class TestFruit(unittest.TestCase): ) # model._var_name_to_model_instances maps the variable name to the # model instances which store that variable + print(fruit._var_name_to_model_instances) self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit], + 'color': [fruit, banana_instance], 'length_cm': [fruit, banana_instance], - 'cultivar': [fruit], - 'origin': [fruit], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) # if we modify one of the properties owned by multiple @@ -140,21 +162,15 @@ class TestFruit(unittest.TestCase): with self.assertRaises(petstore_api.ApiValueError): some_length_cm = fruit.length_cm - # including extra parameters raises an exception - with self.assertRaises(petstore_api.ApiValueError): - fruit = Fruit( - color=color, - length_cm=length_cm, - unknown_property='some value' - ) - # including input parameters for two oneOf instances raise an exception with self.assertRaises(petstore_api.ApiValueError): fruit = Fruit( - length_cm=length_cm, + length_cm=self.length_cm, cultivar='granny smith' ) + def test_apple_fruit(self): + # make an instance of Fruit, a composed schema oneOf model # apple test color = 'red' @@ -190,19 +206,15 @@ class TestFruit(unittest.TestCase): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit], - 'length_cm': [fruit], + 'color': [fruit, apple_instance], 'cultivar': [fruit, apple_instance], - 'origin': [fruit, apple_instance], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) - def testFruitNullValue(self): + def test_null_fruit(self): # Since 'apple' is nullable, validate we can create an apple with the 'null' value. fruit = apple.Apple(None) self.assertIsNone(fruit) @@ -220,5 +232,16 @@ class TestFruit(unittest.TestCase): fruit = Fruit(apple.Apple(None)) self.assertIsNone(fruit) + def test_fruit_with_invalid_input_type(self): + + """ + color must be a str, color's str type is only defined at the Fruit level + Banana + Apple would allow color to be assigned with any type of value + """ + invalid_value = 1 + with self.assertRaises(petstore_api.ApiTypeError): + fruit = Fruit(color=invalid_value, length_cm=self.length_cm) + + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fruit_req.py b/samples/openapi3/client/petstore/python/tests_manual/test_fruit_req.py index 3e637c3226a..64b710fdd58 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fruit_req.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fruit_req.py @@ -14,21 +14,14 @@ import sys import unittest import petstore_api -try: - from petstore_api.model import apple_req -except ImportError: - apple_req = sys.modules[ - 'petstore_api.model.apple_req'] -try: - from petstore_api.model import banana_req -except ImportError: - banana_req = sys.modules[ - 'petstore_api.model.banana_req'] +from petstore_api.model import apple_req +from petstore_api.model import banana_req from petstore_api.model.fruit_req import FruitReq class TestFruitReq(unittest.TestCase): """FruitReq unit test stubs""" + length_cm = 20.3 def setUp(self): pass @@ -36,24 +29,9 @@ class TestFruitReq(unittest.TestCase): def tearDown(self): pass - def testFruitReq(self): - """Test FruitReq""" + def test_fruit_access_errors(self): + fruit = FruitReq(length_cm=self.length_cm) - # make an instance of Fruit, a composed schema oneOf model - # banana test - length_cm = 20.3 - fruit = FruitReq(length_cm=length_cm) - # check its properties - self.assertEqual(fruit.length_cm, length_cm) - self.assertEqual(fruit['length_cm'], length_cm) - self.assertEqual(getattr(fruit, 'length_cm'), length_cm) - # check the dict representation - self.assertEqual( - fruit.to_dict(), - { - 'length_cm': length_cm, - } - ) # setting a value that doesn't exist raises an exception # with a key with self.assertRaises(AttributeError): @@ -66,12 +44,31 @@ class TestFruitReq(unittest.TestCase): # with a key with self.assertRaises(AttributeError): invalid_variable = fruit['cultivar'] - # with getattr - self.assertEqual(getattr(fruit, 'cultivar', 'some value'), 'some value') with self.assertRaises(AttributeError): getattr(fruit, 'cultivar') + def test_FruitReq_banana(self): + """Test FruitReq""" + + # make an instance of Fruit, a composed schema oneOf model + # banana test + fruit = FruitReq(length_cm=self.length_cm) + # check its properties + self.assertEqual(fruit.length_cm, self.length_cm) + self.assertEqual(fruit['length_cm'], self.length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), self.length_cm) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'length_cm': self.length_cm, + } + ) + + # with getattr + self.assertEqual(getattr(fruit, 'cultivar', 'some value'), 'some value') + # make sure that the ModelComposed class properties are correct # model._composed_schemas stores the anyOf/allOf/oneOf info self.assertEqual( @@ -101,15 +98,10 @@ class TestFruitReq(unittest.TestCase): fruit._var_name_to_model_instances, { 'length_cm': [fruit, banana_instance], - 'cultivar': [fruit], - 'mealy': [fruit], - 'sweet': [fruit, banana_instance], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) # if we modify one of the properties owned by multiple @@ -119,21 +111,24 @@ class TestFruitReq(unittest.TestCase): with self.assertRaises(petstore_api.ApiValueError): some_length_cm = fruit.length_cm + def test_invalid_inputs(self): # including extra parameters raises an exception with self.assertRaises(petstore_api.ApiValueError): fruit = FruitReq( - length_cm=length_cm, + length_cm=self.length_cm, unknown_property='some value' ) # including input parameters for two oneOf instances raise an exception with self.assertRaises(petstore_api.ApiValueError): fruit = FruitReq( - length_cm=length_cm, + length_cm=self.length_cm, cultivar='granny smith' ) - # make an instance of Fruit, a composed schema oneOf model + def test_FruitReq_apple(self): + """Test FruitReq""" + # apple test cultivar = 'golden delicious' fruit = FruitReq(cultivar=cultivar) @@ -163,21 +158,18 @@ class TestFruitReq(unittest.TestCase): self.assertEqual( fruit._var_name_to_model_instances, { - 'length_cm': [fruit], 'cultivar': [fruit, apple_instance], - 'mealy': [fruit, apple_instance], - 'sweet': [fruit], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) + def test_null_fruit(self): # we can pass in None fruit = FruitReq(None) assert fruit is None + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py b/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py index 85d0fcf9b1c..ad5907ee443 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py @@ -14,21 +14,15 @@ import sys import unittest import petstore_api -try: - from petstore_api.model import apple -except ImportError: - apple = sys.modules[ - 'petstore_api.model.apple'] -try: - from petstore_api.model import banana -except ImportError: - banana = sys.modules[ - 'petstore_api.model.banana'] +from petstore_api.model import apple +from petstore_api.model import banana from petstore_api.model.gm_fruit import GmFruit class TestGmFruit(unittest.TestCase): """GmFruit unit test stubs""" + length_cm = 20.3 + color = 'yellow' def setUp(self): pass @@ -36,36 +30,48 @@ class TestGmFruit(unittest.TestCase): def tearDown(self): pass - def testGmFruit(self): + def test_set_addprop_attributes(self): + # setting a value that doesn't exist works because additional_properties_type allows any type + other_fruit = GmFruit(length_cm=self.length_cm, color=self.color) + blah = 'blah' + other_fruit['a'] = blah + assert other_fruit.a == blah + + # with setattr + setattr(other_fruit, 'b', blah) + assert other_fruit.b == blah + + self.assertEqual( + other_fruit.to_dict(), + { + 'a': 'blah', + 'b': 'blah', + 'length_cm': self.length_cm, + 'color': self.color + } + ) + + def test_banana_fruit(self): """Test GmFruit""" # make an instance of GmFruit, a composed schema anyOf model # banana test - length_cm = 20.3 - color = 'yellow' - fruit = GmFruit(length_cm=length_cm, color=color) + fruit = GmFruit(length_cm=self.length_cm, color=self.color) # check its properties - self.assertEqual(fruit.length_cm, length_cm) - self.assertEqual(fruit['length_cm'], length_cm) - self.assertEqual(getattr(fruit, 'length_cm'), length_cm) - self.assertEqual(fruit.color, color) - self.assertEqual(fruit['color'], color) - self.assertEqual(getattr(fruit, 'color'), color) + self.assertEqual(fruit.length_cm, self.length_cm) + self.assertEqual(fruit['length_cm'], self.length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), self.length_cm) + self.assertEqual(fruit.color, self.color) + self.assertEqual(fruit['color'], self.color) + self.assertEqual(getattr(fruit, 'color'), self.color) # check the dict representation self.assertEqual( fruit.to_dict(), { - 'length_cm': length_cm, - 'color': color + 'length_cm': self.length_cm, + 'color': self.color } ) - # setting a value that doesn't exist raises an exception - # with a key - with self.assertRaises(AttributeError): - fruit['invalid_variable'] = 'some value' - # with setattr - with self.assertRaises(AttributeError): - setattr(fruit, 'invalid_variable', 'some value') # getting a value that doesn't exist raises an exception # with a key @@ -104,40 +110,22 @@ class TestGmFruit(unittest.TestCase): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit], + 'color': [fruit, banana_instance], 'length_cm': [fruit, banana_instance], - 'cultivar': [fruit], - 'origin': [fruit], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) - # if we modify one of the properties owned by multiple - # model_instances we get an exception when we try to access that - # property because the retrieved values are not all the same - banana_instance.length_cm = 4.56 - with self.assertRaises(petstore_api.ApiValueError): - some_length_cm = fruit.length_cm - - # including extra parameters raises an exception - with self.assertRaises(petstore_api.ApiValueError): - fruit = GmFruit( - color=color, - length_cm=length_cm, - unknown_property='some value' - ) - + def test_combo_fruit(self): # including input parameters for both anyOf instances works cultivar = 'banaple' color = 'orange' fruit = GmFruit( color=color, cultivar=cultivar, - length_cm=length_cm + length_cm=self.length_cm ) self.assertEqual(fruit.color, color) self.assertEqual(fruit['color'], color) @@ -145,9 +133,9 @@ class TestGmFruit(unittest.TestCase): self.assertEqual(fruit.cultivar, cultivar) self.assertEqual(fruit['cultivar'], cultivar) self.assertEqual(getattr(fruit, 'cultivar'), cultivar) - self.assertEqual(fruit.length_cm, length_cm) - self.assertEqual(fruit['length_cm'], length_cm) - self.assertEqual(getattr(fruit, 'length_cm'), length_cm) + self.assertEqual(fruit.length_cm, self.length_cm) + self.assertEqual(fruit['length_cm'], self.length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), self.length_cm) # model._composed_instances is a list of the instances that were # made from the anyOf/allOf/OneOf classes in model._composed_schemas @@ -165,14 +153,16 @@ class TestGmFruit(unittest.TestCase): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit], - 'length_cm': [fruit, banana_instance], - 'cultivar': [fruit, apple_instance], - 'origin': [fruit, apple_instance], + 'color': [fruit, apple_instance, banana_instance], + 'length_cm': [fruit, apple_instance, banana_instance], + 'cultivar': [fruit, apple_instance, banana_instance], } ) + self.assertEqual( + fruit._additional_properties_model_instances, [fruit] + ) - # make an instance of GmFruit, a composed schema anyOf model + def test_apple_fruit(self): # apple test color = 'red' cultivar = 'golden delicious' @@ -214,16 +204,13 @@ class TestGmFruit(unittest.TestCase): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit], - 'length_cm': [fruit], + 'color': [fruit, apple_instance], 'cultivar': [fruit, apple_instance], 'origin': [fruit, apple_instance], } ) - # model._additional_properties_model_instances stores a list of - # models which have the property additional_properties_type != None self.assertEqual( - fruit._additional_properties_model_instances, [] + fruit._additional_properties_model_instances, [fruit] ) if __name__ == '__main__': diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_tag.py b/samples/openapi3/client/petstore/python/tests_manual/test_tag.py new file mode 100644 index 00000000000..ec945f6b30b --- /dev/null +++ b/samples/openapi3/client/petstore/python/tests_manual/test_tag.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.tag import Tag + + +class TestTag(unittest.TestCase): + """Tag unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_can_ingest_additional_properties_in_tag(self): + t = Tag(a='abc') + assert t.a == 'abc' + + +if __name__ == '__main__': + unittest.main() From 26ca6ab27efb31b59f37d8b9bb50cb495d4c236e Mon Sep 17 00:00:00 2001 From: Noor Dawod Date: Wed, 31 Mar 2021 17:53:22 +0200 Subject: [PATCH 07/99] [Dart2] Add initial support to use an isolate to offload JSON serialization/deserialization (#9100) * Change signature of deserialize() to be a Future. * Grammar tlc for a couple of sentences. * Make serialize() use a Future also. * Add useCompute as a parameter to ApiClient, adjust to use compute when serializing/deserializing. * Updated Pet Store client code. * Ordered imports. * Remove Flutter-specific implementation. * Rename global functions to serialize/deserialize JSON. * Fix return type for apiClientSerialize. * Updated pet store client code. * Remove remark for _deserialize. * Make _decodeBodyBytes a Future function. * Updated pet store client code. * Use await when calling serialize(). * Fix a grammatical error. * Adjust doc. * Centralize deserialization code in one function. * Updated pet store client code. * Add await to serialize() in few more tests. * Make output look better for linting and humans. * Updated pet store code. * Add an empty line. * Updated pet store code. * Call the right serializer. * Reuse same variable. * Updated pet store code. * Fix a logical error when deserializing. * Calculate growable once. * Ignore reassignment. * Adjust a test. * Regenerate petstore code. * Revert back previous test. * Use serialize() for testing. * Revert using serialize() for testing. * Add removal deprecation for serialize/deserialize. * Updated petstore code. * Updated deprecation note. * Adjust tests to wait for futures. --- .../src/main/resources/dart2/api.mustache | 8 +- .../main/resources/dart2/api_client.mustache | 131 +++++++++++------ .../main/resources/dart2/api_helper.mustache | 2 +- .../src/main/resources/dart2/apilib.mustache | 3 +- .../petstore/test/pet_faked_client_test.dart | 67 +++++---- .../dart2/petstore/test/pet_test.dart | 22 ++- .../test/store_faked_client_test.dart | 10 +- .../petstore/test/user_faked_client_test.dart | 36 ++--- .../dart2/petstore_client_lib/lib/api.dart | 1 - .../petstore_client_lib/lib/api/pet_api.dart | 24 ++-- .../lib/api/store_api.dart | 14 +- .../petstore_client_lib/lib/api/user_api.dart | 20 +-- .../petstore_client_lib/lib/api_client.dart | 133 ++++++++++++------ .../petstore_client_lib/lib/api_helper.dart | 2 +- .../petstore/test/pet_faked_client_test.dart | 83 ++++++----- .../dart2/petstore/test/pet_test.dart | 22 ++- .../test/store_faked_client_test.dart | 10 +- .../petstore/test/user_faked_client_test.dart | 48 ++++--- .../dart2/petstore_client_lib/lib/api.dart | 1 - .../petstore_client_lib/lib/api/pet_api.dart | 28 ++-- .../lib/api/store_api.dart | 14 +- .../petstore_client_lib/lib/api/user_api.dart | 20 +-- .../petstore_client_lib/lib/api_client.dart | 133 ++++++++++++------ .../petstore_client_lib/lib/api_helper.dart | 2 +- .../petstore_client_lib_fake/lib/api.dart | 1 - .../lib/api/another_fake_api.dart | 4 +- .../lib/api/default_api.dart | 4 +- .../lib/api/fake_api.dart | 46 +++--- .../lib/api/fake_classname_tags123_api.dart | 4 +- .../lib/api/pet_api.dart | 28 ++-- .../lib/api/store_api.dart | 14 +- .../lib/api/user_api.dart | 20 +-- .../lib/api_client.dart | 133 ++++++++++++------ .../lib/api_helper.dart | 2 +- .../lib/api.dart | 3 +- .../lib/api/another_fake_api.dart | 2 +- .../lib/api/default_api.dart | 2 +- .../lib/api/fake_api.dart | 32 ++--- .../lib/api/fake_classname_tags123_api.dart | 2 +- .../lib/api/pet_api.dart | 18 +-- .../lib/api/store_api.dart | 8 +- .../lib/api/user_api.dart | 16 +-- .../lib/api_client.dart | 22 +-- .../lib/api_helper.dart | 2 +- 44 files changed, 700 insertions(+), 497 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart2/api.mustache b/modules/openapi-generator/src/main/resources/dart2/api.mustache index 61ecab963b6..d99ba2b325f 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api.mustache @@ -178,7 +178,7 @@ class {{{classname}}} { Future<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async { final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}}); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } {{#returnType}} // When a remote server returns no body with a status of 204, we shall not decode it. @@ -187,16 +187,16 @@ class {{{classname}}} { if (response.body != null && response.statusCode != HttpStatus.noContent) { {{#native_serialization}} {{#isArray}} - return (apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}') as List) .cast<{{{returnBaseType}}}>() .{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}}; {{/isArray}} {{^isArray}} {{#isMap}} - return {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}')); + return {{{returnType}}}.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}'),); {{/isMap}} {{^isMap}} - return apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as {{{returnType}}}; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}}; {{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}} {{#isArray}} {{#uniqueItems}} diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache index a5d3b0948e7..167b6951e01 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache @@ -51,17 +51,16 @@ class ApiClient { Map get defaultHeaderMap => _defaultHeaderMap; - /// returns an unmodifiable view of the authentications, since none should be added - /// nor deleted - Map get authentications => - Map.unmodifiable(_authentications); + /// Returns an unmodifiable [Map] of the authentications, since none should be added + /// or deleted. + Map get authentications => Map.unmodifiable(_authentications); T getAuthentication(String name) { final authentication = _authentications[name]; return authentication is T ? authentication : null; } - // We don’t use a Map for queryParams. + // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( String path, @@ -92,7 +91,7 @@ class ApiClient { } try { - // Special case for uploading a single file which isn’t a 'multipart/form-data'. + // Special case for uploading a single file which isn't a 'multipart/form-data'. if ( body is MultipartFile && (nullableContentType == null || !nullableContentType.toLowerCase().startsWith('multipart/form-data')) @@ -122,7 +121,7 @@ class ApiClient { final msgBody = nullableContentType == 'application/x-www-form-urlencoded' ? formParams - : serialize(body); + : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; switch(method) { @@ -147,9 +146,48 @@ class ApiClient { throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',); } +{{#native_serialization}} + + Future deserializeAsync(String json, String targetType, {bool growable}) async => + // ignore: deprecated_member_use_from_same_package + deserialize(json, targetType, growable: growable); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.') + dynamic deserialize(String json, String targetType, {bool growable}) { + // Remove all spaces. Necessary for regular expressions as well. + targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? json + : _deserialize(jsonDecode(json), targetType, growable: growable == true); + } +{{/native_serialization}} + + // ignore: deprecated_member_use_from_same_package + Future serializeAsync(Object value) async => serialize(value); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') + String serialize(Object value) => value == null ? '' : json.encode(value); + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth( + List authNames, + List queryParams, + Map headerParams, + ) { + authNames.forEach((authName) { + final auth = _authentications[authName]; + if (auth == null) { + throw ArgumentError('Authentication undefined: $authName'); + } + auth.applyToParams(queryParams, headerParams); + }); + } {{#native_serialization}} - dynamic _deserialize(dynamic value, String targetType, {bool growable}) { + static dynamic _deserialize(dynamic value, String targetType, {bool growable}) { try { switch (targetType) { case 'String': @@ -180,57 +218,68 @@ class ApiClient { default: Match match; if (value is List && (match = _regList.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) - .toList(growable: true == growable); + .map((v) => _deserialize(v, targetType, growable: growable)) + .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) + .map((v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return Map.fromIterables( value.keys, - value.values.map((v) => _deserialize(v, newTargetType, growable: growable)), + value.values.map((v) => _deserialize(v, targetType, growable: growable)), ); } break; } - } on Exception catch (e, stack) { - throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,); + } catch (error, trace) { + throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); } +{{/native_serialization}} +} +{{#native_serialization}} - dynamic deserialize(String json, String targetType, {bool growable}) { - // Remove all spaces. Necessary for reg expressions as well. - targetType = targetType.replaceAll(' ', ''); +/// Primarily intended for use in an isolate. +class DeserializationMessage { + const DeserializationMessage({ + @required this.json, + @required this.targetType, + this.growable, + }); + /// The JSON value to deserialize. + final String json; + + /// Target type to deserialize to. + final String targetType; + + /// Whether to make deserialized lists or maps growable. + final bool growable; +} + +/// Primarily intended for use in an isolate. +Future deserializeAsync(DeserializationMessage message) async { + // Remove all spaces. Necessary for regular expressions as well. + final targetType = message.targetType.replaceAll(' ', ''); + + // If the expected target type is String, nothing to do... return targetType == 'String' - ? json - : _deserialize(jsonDecode(json), targetType, growable: true == growable); - } + ? message.json + : ApiClient._deserialize( + jsonDecode(message.json), + targetType, + growable: message.growable == true, + ); +} {{/native_serialization}} - String serialize(Object obj) => obj == null ? '' : json.encode(obj); - - /// Update query and header parameters based on authentication settings. - /// @param authNames The authentications to apply - void _updateParamsForAuth( - List authNames, - List queryParams, - Map headerParams, - ) { - authNames.forEach((authName) { - final auth = _authentications[authName]; - if (auth == null) { - throw ArgumentError('Authentication undefined: $authName'); - } - auth.applyToParams(queryParams, headerParams); - }); - } -} +/// Primarily intended for use in an isolate. +Future serializeAsync(Object value) async => value == null ? '' : json.encode(value); diff --git a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache index 8e70b9920bf..92f394176f6 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache @@ -63,7 +63,7 @@ String parameterToString(dynamic value) { /// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json' /// content type. Otherwise, returns the decoded body as decoded by dart:http package. -String _decodeBodyBytes(Response response) { +Future _decodeBodyBytes(Response response) async { final contentType = response.headers['content-type']; return contentType != null && contentType.toLowerCase().startsWith('application/json') ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) diff --git a/modules/openapi-generator/src/main/resources/dart2/apilib.mustache b/modules/openapi-generator/src/main/resources/dart2/apilib.mustache index e17f4ed139a..df10d804011 100644 --- a/modules/openapi-generator/src/main/resources/dart2/apilib.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/apilib.mustache @@ -7,11 +7,10 @@ import 'dart:io'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; - -import 'package:meta/meta.dart'; {{#json_serializable}} import 'package:json_annotation/json_annotation.dart'; {{/json_serializable}} +import 'package:meta/meta.dart'; part 'api_client.dart'; part 'api_helper.dart'; diff --git a/samples/client/petstore/dart2/petstore/test/pet_faked_client_test.dart b/samples/client/petstore/dart2/petstore/test/pet_faked_client_test.dart index 0b80d597c6c..7d18af8762b 100644 --- a/samples/client/petstore/dart2/petstore/test/pet_faked_client_test.dart +++ b/samples/client/petstore/dart2/petstore/test/pet_faked_client_test.dart @@ -39,7 +39,7 @@ void main() { Future addPet(Pet pet) { petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(pet), + expectedPostRequestBody: await petApi.apiClient.serializeAsync(pet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); return petApi.addPet(pet); @@ -53,7 +53,8 @@ void main() { // use the pet api to add a pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -61,7 +62,7 @@ void main() { // retrieve the same pet by id petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(newPet), + getResponseBody: await petApi.apiClient.serializeAsync(newPet), ); final retrievedPet = await petApi.getPetById(id); @@ -86,7 +87,8 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -115,7 +117,8 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -139,7 +142,7 @@ void main() { newPet.name = 'Doge'; petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(newPet), + getResponseBody: await petApi.apiClient.serializeAsync(newPet), ); final pet = await petApi.getPetById(id); expect(pet.name, equals('Doge')); @@ -154,7 +157,8 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -162,7 +166,8 @@ void main() { // update the same pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPutRequestBody: petApi.apiClient.serialize(updatePet), + expectedPutRequestBody: + await petApi.apiClient.serializeAsync(updatePet), putResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.updatePet(updatePet); @@ -170,7 +175,7 @@ void main() { // check update worked petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(updatePet), + getResponseBody: await petApi.apiClient.serializeAsync(updatePet), ); final pet = await petApi.getPetById(id); expect(pet.name, equals(name)); @@ -180,30 +185,31 @@ void main() { final id1 = newId(); final id2 = newId(); final id3 = newId(); - final status = PetStatusEnum.available.value; + final status = '${PetStatusEnum.available}'; final pet1 = makePet(id: id1, status: status); final pet2 = makePet(id: id2, status: status); - final pet3 = makePet(id: id3, status: PetStatusEnum.sold.value); + final pet3 = makePet(id: id3, status: '${PetStatusEnum.sold}'); - return Future.wait([addPet(pet1), addPet(pet2), addPet(pet3)]) - .then((_) async { - // retrieve pets by status - petApi.apiClient.client = FakeClient( - expectedUrl: - 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status', - getResponseBody: petApi.apiClient.serialize([pet1, pet2]), - ); - final pets = await petApi.findPetsByStatus([status]); + await addPet(pet1); + await addPet(pet2); + await addPet(pet3); - // tests serialisation and deserialisation of enum - final petsByStatus = - pets.where((p) => p.status == PetStatusEnum.available); - expect(petsByStatus.length, equals(2)); - final petIds = pets.map((pet) => pet.id).toList(); - expect(petIds, contains(id1)); - expect(petIds, contains(id2)); - expect(petIds, isNot(contains(id3))); - }); + // retrieve pets by status + petApi.apiClient.client = FakeClient( + expectedUrl: + 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status', + getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]), + ); + final pets = await petApi.findPetsByStatus([status]); + + // tests serialisation and deserialisation of enum + final petsByStatus = + pets.where((p) => p.status == PetStatusEnum.available); + expect(petsByStatus.length, equals(2)); + final petIds = pets.map((pet) => pet.id).toList(); + expect(petIds, contains(id1)); + expect(petIds, contains(id2)); + expect(petIds, isNot(contains(id3))); }); test('uploads a pet image', () async { @@ -216,7 +222,8 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), postResponseBody: '', expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); diff --git a/samples/client/petstore/dart2/petstore/test/pet_test.dart b/samples/client/petstore/dart2/petstore/test/pet_test.dart index e480ec7baa0..72126ba6a90 100644 --- a/samples/client/petstore/dart2/petstore/test/pet_test.dart +++ b/samples/client/petstore/dart2/petstore/test/pet_test.dart @@ -81,19 +81,17 @@ void main() { var id1 = newId(); var id2 = newId(); var id3 = newId(); - var status = PetStatusEnum.available.value; + var status = '${PetStatusEnum.available}'; - return Future.wait([ - petApi.addPet(makePet(id: id1, status: status)), - petApi.addPet(makePet(id: id2, status: status)), - petApi.addPet(makePet(id: id3, status: PetStatusEnum.sold.value)) - ]).then((_) async { - var pets = await petApi.findPetsByStatus([status]); - var petIds = pets.map((pet) => pet.id).toList(); - expect(petIds, contains(id1)); - expect(petIds, contains(id2)); - expect(petIds, isNot(contains(id3))); - }); + await petApi.addPet(makePet(id: id1, status: status)); + await petApi.addPet(makePet(id: id2, status: status)); + await petApi.addPet(makePet(id: id3, status: '${PetStatusEnum.sold}')); + + var pets = await petApi.findPetsByStatus([status]); + var petIds = pets.map((pet) => pet.id).toList(); + expect(petIds, contains(id1)); + expect(petIds, contains(id2)); + expect(petIds, isNot(contains(id3))); }); test('uploads a pet image', () async { diff --git a/samples/client/petstore/dart2/petstore/test/store_faked_client_test.dart b/samples/client/petstore/dart2/petstore/test/store_faked_client_test.dart index 5ebdc63861d..9f75fd55d86 100644 --- a/samples/client/petstore/dart2/petstore/test/store_faked_client_test.dart +++ b/samples/client/petstore/dart2/petstore/test/store_faked_client_test.dart @@ -28,8 +28,8 @@ void main() { // // use the store api to add an order // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order', - // expectedPostRequestBody: storeApi.apiClient.serialize(newOrder), - // postResponseBody: storeApi.apiClient.serialize(newOrder), + // expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder), + // postResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // expectedHeaders: {"Content-Type": "application/json"} // ); // await storeApi.placeOrder(newOrder); @@ -37,7 +37,7 @@ void main() { // // retrieve the same order by id // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id', - // getResponseBody: storeApi.apiClient.serialize(newOrder), + // getResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // ); // final placedOrder = await storeApi.getOrderById(id); // expect(placedOrder.id, equals(id)); @@ -51,8 +51,8 @@ void main() { // // use the store api to add an order // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order', - // expectedPostRequestBody: storeApi.apiClient.serialize(newOrder), - // postResponseBody: storeApi.apiClient.serialize(newOrder), + // expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder), + // postResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // expectedHeaders: {"Content-Type": "application/json"} // ); // await storeApi.placeOrder(newOrder); diff --git a/samples/client/petstore/dart2/petstore/test/user_faked_client_test.dart b/samples/client/petstore/dart2/petstore/test/user_faked_client_test.dart index df2b4686f13..53cc659a8f2 100644 --- a/samples/client/petstore/dart2/petstore/test/user_faked_client_test.dart +++ b/samples/client/petstore/dart2/petstore/test/user_faked_client_test.dart @@ -29,15 +29,16 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); // retrieve the same user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/$username', - getResponseBody: userApi.apiClient.serialize(newUser), + getResponseBody: await userApi.apiClient.serializeAsync(newUser), ); var user = await userApi.getUserByName(username); expect(user.id, equals(id)); @@ -58,8 +59,8 @@ void main() { // use the user api to create a list of users userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList', - expectedPostRequestBody: userApi.apiClient.serialize(users), - postResponseBody: userApi.apiClient.serialize(users), + expectedPostRequestBody: await userApi.apiClient.serializeAsync(users), + postResponseBody: await userApi.apiClient.serializeAsync(users), ); await userApi.createUsersWithListInput(users); @@ -67,7 +68,7 @@ void main() { userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}', - getResponseBody: userApi.apiClient.serialize( + getResponseBody: await userApi.apiClient.serializeAsync( users.elementAt(0), ), ); @@ -75,7 +76,7 @@ void main() { userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}', - getResponseBody: userApi.apiClient.serialize( + getResponseBody: await userApi.apiClient.serializeAsync( users.elementAt(1), ), ); @@ -92,8 +93,9 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); newUser.email = email; @@ -101,15 +103,15 @@ void main() { // use the user api to update the user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}', - expectedPutRequestBody: userApi.apiClient.serialize(newUser), - putResponseBody: userApi.apiClient.serialize(newUser), + expectedPutRequestBody: await userApi.apiClient.serializeAsync(newUser), + putResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.updateUser(username, newUser); // retrieve the same user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}', - getResponseBody: userApi.apiClient.serialize(newUser), + getResponseBody: await userApi.apiClient.serializeAsync(newUser), ); var foundUser = await userApi.getUserByName(username); expect(foundUser.email, equals(email)); @@ -122,8 +124,9 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); @@ -152,8 +155,9 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart index ba25916af59..f6bf3e75908 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart @@ -15,7 +15,6 @@ import 'dart:io'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; - import 'package:meta/meta.dart'; part 'api_client.dart'; diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart index c6446b85653..b38cbce1d3a 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart @@ -74,7 +74,7 @@ class PetApi { Future addPet(Pet body) async { final response = await addPetWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -146,7 +146,7 @@ class PetApi { Future deletePet(int petId, { String apiKey }) async { final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -215,13 +215,13 @@ class PetApi { Future> findPetsByStatus(List status) async { final response = await findPetsByStatusWithHttpInfo(status); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'List') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) .cast() .toList(growable: false); } @@ -293,13 +293,13 @@ class PetApi { Future> findPetsByTags(List tags) async { final response = await findPetsByTagsWithHttpInfo(tags); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'List') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) .cast() .toList(growable: false); } @@ -370,13 +370,13 @@ class PetApi { Future getPetById(int petId) async { final response = await getPetByIdWithHttpInfo(petId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } return Future.value(null); } @@ -440,7 +440,7 @@ class PetApi { Future updatePet(Pet body) async { final response = await updatePetWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -530,7 +530,7 @@ class PetApi { Future updatePetWithForm(int petId, { String name, String status }) async { final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -618,13 +618,13 @@ class PetApi { Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } return Future.value(null); } diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart index 490860ed8c2..836d4ca8b0b 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart @@ -79,7 +79,7 @@ class StoreApi { Future deleteOrder(String orderId) async { final response = await deleteOrderWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -131,13 +131,13 @@ class StoreApi { Future> getInventory() async { final response = await getInventoryWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return Map.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map')); + return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),); } return Future>.value(null); } @@ -206,13 +206,13 @@ class StoreApi { Future getOrderById(int orderId) async { final response = await getOrderByIdWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } @@ -276,13 +276,13 @@ class StoreApi { Future placeOrder(Order body) async { final response = await placeOrderWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart index f643e2e5dab..93b55fd2c41 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart @@ -78,7 +78,7 @@ class UserApi { Future createUser(User body) async { final response = await createUserWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -141,7 +141,7 @@ class UserApi { Future createUsersWithArrayInput(List body) async { final response = await createUsersWithArrayInputWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -204,7 +204,7 @@ class UserApi { Future createUsersWithListInput(List body) async { final response = await createUsersWithListInputWithHttpInfo(body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -272,7 +272,7 @@ class UserApi { Future deleteUser(String username) async { final response = await deleteUserWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -336,13 +336,13 @@ class UserApi { Future getUserByName(String username) async { final response = await getUserByNameWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User; } return Future.value(null); } @@ -418,13 +418,13 @@ class UserApi { Future loginUser(String username, String password) async { final response = await loginUserWithHttpInfo(username, password); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } return Future.value(null); } @@ -473,7 +473,7 @@ class UserApi { Future logoutUser() async { final response = await logoutUserWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -550,7 +550,7 @@ class UserApi { Future updateUser(String username, User body) async { final response = await updateUserWithHttpInfo(username, body); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart index 87a7a36d470..c847d27f60b 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart @@ -44,17 +44,16 @@ class ApiClient { Map get defaultHeaderMap => _defaultHeaderMap; - /// returns an unmodifiable view of the authentications, since none should be added - /// nor deleted - Map get authentications => - Map.unmodifiable(_authentications); + /// Returns an unmodifiable [Map] of the authentications, since none should be added + /// or deleted. + Map get authentications => Map.unmodifiable(_authentications); T getAuthentication(String name) { final authentication = _authentications[name]; return authentication is T ? authentication : null; } - // We don’t use a Map for queryParams. + // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( String path, @@ -85,7 +84,7 @@ class ApiClient { } try { - // Special case for uploading a single file which isn’t a 'multipart/form-data'. + // Special case for uploading a single file which isn't a 'multipart/form-data'. if ( body is MultipartFile && (nullableContentType == null || !nullableContentType.toLowerCase().startsWith('multipart/form-data')) @@ -115,7 +114,7 @@ class ApiClient { final msgBody = nullableContentType == 'application/x-www-form-urlencoded' ? formParams - : serialize(body); + : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; switch(method) { @@ -141,7 +140,44 @@ class ApiClient { throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',); } - dynamic _deserialize(dynamic value, String targetType, {bool growable}) { + Future deserializeAsync(String json, String targetType, {bool growable}) async => + // ignore: deprecated_member_use_from_same_package + deserialize(json, targetType, growable: growable); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.') + dynamic deserialize(String json, String targetType, {bool growable}) { + // Remove all spaces. Necessary for regular expressions as well. + targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? json + : _deserialize(jsonDecode(json), targetType, growable: growable == true); + } + + // ignore: deprecated_member_use_from_same_package + Future serializeAsync(Object value) async => serialize(value); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') + String serialize(Object value) => value == null ? '' : json.encode(value); + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth( + List authNames, + List queryParams, + Map headerParams, + ) { + authNames.forEach((authName) { + final auth = _authentications[authName]; + if (auth == null) { + throw ArgumentError('Authentication undefined: $authName'); + } + auth.applyToParams(queryParams, headerParams); + }); + } + + static dynamic _deserialize(dynamic value, String targetType, {bool growable}) { try { switch (targetType) { case 'String': @@ -172,56 +208,65 @@ class ApiClient { default: Match match; if (value is List && (match = _regList.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) - .toList(growable: true == growable); + .map((v) => _deserialize(v, targetType, growable: growable)) + .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) + .map((v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return Map.fromIterables( value.keys, - value.values.map((v) => _deserialize(v, newTargetType, growable: growable)), + value.values.map((v) => _deserialize(v, targetType, growable: growable)), ); } break; } - } on Exception catch (e, stack) { - throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,); + } catch (error, trace) { + throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); } - - dynamic deserialize(String json, String targetType, {bool growable}) { - // Remove all spaces. Necessary for reg expressions as well. - targetType = targetType.replaceAll(' ', ''); - - return targetType == 'String' - ? json - : _deserialize(jsonDecode(json), targetType, growable: true == growable); - } - - String serialize(Object obj) => obj == null ? '' : json.encode(obj); - - /// Update query and header parameters based on authentication settings. - /// @param authNames The authentications to apply - void _updateParamsForAuth( - List authNames, - List queryParams, - Map headerParams, - ) { - authNames.forEach((authName) { - final auth = _authentications[authName]; - if (auth == null) { - throw ArgumentError('Authentication undefined: $authName'); - } - auth.applyToParams(queryParams, headerParams); - }); - } } + +/// Primarily intended for use in an isolate. +class DeserializationMessage { + const DeserializationMessage({ + @required this.json, + @required this.targetType, + this.growable, + }); + + /// The JSON value to deserialize. + final String json; + + /// Target type to deserialize to. + final String targetType; + + /// Whether to make deserialized lists or maps growable. + final bool growable; +} + +/// Primarily intended for use in an isolate. +Future deserializeAsync(DeserializationMessage message) async { + // Remove all spaces. Necessary for regular expressions as well. + final targetType = message.targetType.replaceAll(' ', ''); + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? message.json + : ApiClient._deserialize( + jsonDecode(message.json), + targetType, + growable: message.growable == true, + ); +} + +/// Primarily intended for use in an isolate. +Future serializeAsync(Object value) async => value == null ? '' : json.encode(value); diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart index 141f4a7f5b4..4135dcf95b2 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart @@ -63,7 +63,7 @@ String parameterToString(dynamic value) { /// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json' /// content type. Otherwise, returns the decoded body as decoded by dart:http package. -String _decodeBodyBytes(Response response) { +Future _decodeBodyBytes(Response response) async { final contentType = response.headers['content-type']; return contentType != null && contentType.toLowerCase().startsWith('application/json') ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) diff --git a/samples/openapi3/client/petstore/dart2/petstore/test/pet_faked_client_test.dart b/samples/openapi3/client/petstore/dart2/petstore/test/pet_faked_client_test.dart index 70f1b0d6beb..277c49b3971 100644 --- a/samples/openapi3/client/petstore/dart2/petstore/test/pet_faked_client_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore/test/pet_faked_client_test.dart @@ -36,11 +36,11 @@ void main() { } /// Setup the fake client then call [petApi.addPet] - Future addPet(Pet pet) { + Future addPet(Pet pet) async { petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(pet), - postResponseBody: petApi.apiClient.serialize(pet), + expectedPostRequestBody: await petApi.apiClient.serializeAsync(pet), + postResponseBody: await petApi.apiClient.serializeAsync(pet), expectedHeaders: {'Content-Type': 'application/json'}); return petApi.addPet(pet); } @@ -53,15 +53,16 @@ void main() { // use the pet api to add a pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), - postResponseBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), + postResponseBody: await petApi.apiClient.serializeAsync(newPet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); // retrieve the same pet by id petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(newPet), + getResponseBody: await petApi.apiClient.serializeAsync(newPet), ); final retrievedPet = await petApi.getPetById(id); @@ -86,8 +87,9 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), - postResponseBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), + postResponseBody: await petApi.apiClient.serializeAsync(newPet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -115,8 +117,9 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), - postResponseBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), + postResponseBody: await petApi.apiClient.serializeAsync(newPet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); @@ -139,7 +142,7 @@ void main() { newPet.name = 'Doge'; petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(newPet), + getResponseBody: await petApi.apiClient.serializeAsync(newPet), ); final pet = await petApi.getPetById(id); expect(pet.name, equals('Doge')); @@ -154,23 +157,25 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), - postResponseBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), + postResponseBody: await petApi.apiClient.serializeAsync(newPet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); // update the same pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPutRequestBody: petApi.apiClient.serialize(updatePet), - putResponseBody: petApi.apiClient.serialize(updatePet), + expectedPutRequestBody: + await petApi.apiClient.serializeAsync(updatePet), + putResponseBody: await petApi.apiClient.serializeAsync(updatePet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.updatePet(updatePet); // check update worked petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet/$id', - getResponseBody: petApi.apiClient.serialize(updatePet), + getResponseBody: await petApi.apiClient.serializeAsync(updatePet), ); final pet = await petApi.getPetById(id); expect(pet.name, equals(name)); @@ -180,30 +185,31 @@ void main() { final id1 = newId(); final id2 = newId(); final id3 = newId(); - final status = PetStatusEnum.available.value; + final status = '${PetStatusEnum.available}'; final pet1 = makePet(id: id1, status: status); final pet2 = makePet(id: id2, status: status); - final pet3 = makePet(id: id3, status: PetStatusEnum.sold.value); + final pet3 = makePet(id: id3, status: '${PetStatusEnum.sold}'); - return Future.wait([addPet(pet1), addPet(pet2), addPet(pet3)]) - .then((_) async { - // retrieve pets by status - petApi.apiClient.client = FakeClient( - expectedUrl: - 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status', - getResponseBody: petApi.apiClient.serialize([pet1, pet2]), - ); - final pets = await petApi.findPetsByStatus([status]); + await addPet(pet1); + await addPet(pet2); + await addPet(pet3); - // tests serialisation and deserialisation of enum - final petsByStatus = - pets.where((p) => p.status == PetStatusEnum.available); - expect(petsByStatus.length, equals(2)); - final petIds = pets.map((pet) => pet.id).toList(); - expect(petIds, contains(id1)); - expect(petIds, contains(id2)); - expect(petIds, isNot(contains(id3))); - }); + // retrieve pets by status + petApi.apiClient.client = FakeClient( + expectedUrl: + 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status', + getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]), + ); + final pets = await petApi.findPetsByStatus([status]); + + // tests serialisation and deserialisation of enum + final petsByStatus = + pets.where((p) => p.status == PetStatusEnum.available); + expect(petsByStatus.length, equals(2)); + final petIds = pets.map((pet) => pet.id).toList(); + expect(petIds, contains(id1)); + expect(petIds, contains(id2)); + expect(petIds, isNot(contains(id3))); }); test('uploads a pet image', () async { @@ -216,8 +222,9 @@ void main() { // add a new pet petApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/pet', - expectedPostRequestBody: petApi.apiClient.serialize(newPet), - postResponseBody: petApi.apiClient.serialize(newPet), + expectedPostRequestBody: + await petApi.apiClient.serializeAsync(newPet), + postResponseBody: await petApi.apiClient.serializeAsync(newPet), expectedHeaders: {'Content-Type': 'application/json'}); await petApi.addPet(newPet); diff --git a/samples/openapi3/client/petstore/dart2/petstore/test/pet_test.dart b/samples/openapi3/client/petstore/dart2/petstore/test/pet_test.dart index e480ec7baa0..72126ba6a90 100644 --- a/samples/openapi3/client/petstore/dart2/petstore/test/pet_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore/test/pet_test.dart @@ -81,19 +81,17 @@ void main() { var id1 = newId(); var id2 = newId(); var id3 = newId(); - var status = PetStatusEnum.available.value; + var status = '${PetStatusEnum.available}'; - return Future.wait([ - petApi.addPet(makePet(id: id1, status: status)), - petApi.addPet(makePet(id: id2, status: status)), - petApi.addPet(makePet(id: id3, status: PetStatusEnum.sold.value)) - ]).then((_) async { - var pets = await petApi.findPetsByStatus([status]); - var petIds = pets.map((pet) => pet.id).toList(); - expect(petIds, contains(id1)); - expect(petIds, contains(id2)); - expect(petIds, isNot(contains(id3))); - }); + await petApi.addPet(makePet(id: id1, status: status)); + await petApi.addPet(makePet(id: id2, status: status)); + await petApi.addPet(makePet(id: id3, status: '${PetStatusEnum.sold}')); + + var pets = await petApi.findPetsByStatus([status]); + var petIds = pets.map((pet) => pet.id).toList(); + expect(petIds, contains(id1)); + expect(petIds, contains(id2)); + expect(petIds, isNot(contains(id3))); }); test('uploads a pet image', () async { diff --git a/samples/openapi3/client/petstore/dart2/petstore/test/store_faked_client_test.dart b/samples/openapi3/client/petstore/dart2/petstore/test/store_faked_client_test.dart index 5ebdc63861d..9f75fd55d86 100644 --- a/samples/openapi3/client/petstore/dart2/petstore/test/store_faked_client_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore/test/store_faked_client_test.dart @@ -28,8 +28,8 @@ void main() { // // use the store api to add an order // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order', - // expectedPostRequestBody: storeApi.apiClient.serialize(newOrder), - // postResponseBody: storeApi.apiClient.serialize(newOrder), + // expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder), + // postResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // expectedHeaders: {"Content-Type": "application/json"} // ); // await storeApi.placeOrder(newOrder); @@ -37,7 +37,7 @@ void main() { // // retrieve the same order by id // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id', - // getResponseBody: storeApi.apiClient.serialize(newOrder), + // getResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // ); // final placedOrder = await storeApi.getOrderById(id); // expect(placedOrder.id, equals(id)); @@ -51,8 +51,8 @@ void main() { // // use the store api to add an order // storeApi.apiClient.client = FakeClient( // expectedUrl: 'http://petstore.swagger.io/v2/store/order', - // expectedPostRequestBody: storeApi.apiClient.serialize(newOrder), - // postResponseBody: storeApi.apiClient.serialize(newOrder), + // expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder), + // postResponseBody: await storeApi.apiClient.serializeAsync(newOrder), // expectedHeaders: {"Content-Type": "application/json"} // ); // await storeApi.placeOrder(newOrder); diff --git a/samples/openapi3/client/petstore/dart2/petstore/test/user_faked_client_test.dart b/samples/openapi3/client/petstore/dart2/petstore/test/user_faked_client_test.dart index 2d549e84fc8..f8137935192 100644 --- a/samples/openapi3/client/petstore/dart2/petstore/test/user_faked_client_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore/test/user_faked_client_test.dart @@ -29,16 +29,17 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - expectedHeaders: { 'Content-Type': 'application/json' }, - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + expectedHeaders: {'Content-Type': 'application/json'}, + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); // retrieve the same user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/$username', - getResponseBody: userApi.apiClient.serialize(newUser), + getResponseBody: await userApi.apiClient.serializeAsync(newUser), ); var user = await userApi.getUserByName(username); expect(user.id, equals(id)); @@ -59,9 +60,9 @@ void main() { // use the user api to create a list of users userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList', - expectedPostRequestBody: userApi.apiClient.serialize(users), - expectedHeaders: { 'Content-Type': 'application/json' }, - postResponseBody: userApi.apiClient.serialize(users), + expectedPostRequestBody: await userApi.apiClient.serializeAsync(users), + expectedHeaders: {'Content-Type': 'application/json'}, + postResponseBody: await userApi.apiClient.serializeAsync(users), ); await userApi.createUsersWithListInput(users); @@ -69,7 +70,7 @@ void main() { userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}', - getResponseBody: userApi.apiClient.serialize( + getResponseBody: await userApi.apiClient.serializeAsync( users.elementAt(0), ), ); @@ -77,7 +78,7 @@ void main() { userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}', - getResponseBody: userApi.apiClient.serialize( + getResponseBody: await userApi.apiClient.serializeAsync( users.elementAt(1), ), ); @@ -94,9 +95,10 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - expectedHeaders: { 'Content-Type': 'application/json' }, - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + expectedHeaders: {'Content-Type': 'application/json'}, + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); newUser.email = email; @@ -104,16 +106,16 @@ void main() { // use the user api to update the user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}', - expectedPutRequestBody: userApi.apiClient.serialize(newUser), - expectedHeaders: { 'Content-Type': 'application/json' }, - putResponseBody: userApi.apiClient.serialize(newUser), + expectedPutRequestBody: await userApi.apiClient.serializeAsync(newUser), + expectedHeaders: {'Content-Type': 'application/json'}, + putResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.updateUser(username, newUser); // retrieve the same user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}', - getResponseBody: userApi.apiClient.serialize(newUser), + getResponseBody: await userApi.apiClient.serializeAsync(newUser), ); var foundUser = await userApi.getUserByName(username); expect(foundUser.email, equals(email)); @@ -126,9 +128,10 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - expectedHeaders: { 'Content-Type': 'application/json' }, - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + expectedHeaders: {'Content-Type': 'application/json'}, + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); @@ -157,9 +160,10 @@ void main() { // use the user api to create a user userApi.apiClient.client = FakeClient( expectedUrl: 'http://petstore.swagger.io/v2/user', - expectedPostRequestBody: userApi.apiClient.serialize(newUser), - expectedHeaders: { 'Content-Type': 'application/json' }, - postResponseBody: userApi.apiClient.serialize(newUser), + expectedPostRequestBody: + await userApi.apiClient.serializeAsync(newUser), + expectedHeaders: {'Content-Type': 'application/json'}, + postResponseBody: await userApi.apiClient.serializeAsync(newUser), ); await userApi.createUser(newUser); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart index ba25916af59..f6bf3e75908 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart @@ -15,7 +15,6 @@ import 'dart:io'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; - import 'package:meta/meta.dart'; part 'api_client.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart index 2f9bc586380..2ec34d475e2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart @@ -74,13 +74,13 @@ class PetApi { Future addPet(Pet pet) async { final response = await addPetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } return Future.value(null); } @@ -153,7 +153,7 @@ class PetApi { Future deletePet(int petId, { String apiKey }) async { final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -222,13 +222,13 @@ class PetApi { Future> findPetsByStatus(List status) async { final response = await findPetsByStatusWithHttpInfo(status); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'List') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) .cast() .toList(growable: false); } @@ -300,13 +300,13 @@ class PetApi { Future> findPetsByTags(List tags) async { final response = await findPetsByTagsWithHttpInfo(tags); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'List') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) .cast() .toList(growable: false); } @@ -377,13 +377,13 @@ class PetApi { Future getPetById(int petId) async { final response = await getPetByIdWithHttpInfo(petId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } return Future.value(null); } @@ -447,13 +447,13 @@ class PetApi { Future updatePet(Pet pet) async { final response = await updatePetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } return Future.value(null); } @@ -544,7 +544,7 @@ class PetApi { Future updatePetWithForm(int petId, { String name, String status }) async { final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -632,13 +632,13 @@ class PetApi { Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart index 76ffaec6faa..9696bacc9de 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart @@ -79,7 +79,7 @@ class StoreApi { Future deleteOrder(String orderId) async { final response = await deleteOrderWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -131,13 +131,13 @@ class StoreApi { Future> getInventory() async { final response = await getInventoryWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return Map.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map')); + return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),); } return Future>.value(null); } @@ -206,13 +206,13 @@ class StoreApi { Future getOrderById(int orderId) async { final response = await getOrderByIdWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } @@ -276,13 +276,13 @@ class StoreApi { Future placeOrder(Order order) async { final response = await placeOrderWithHttpInfo(order); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart index 08847cc2b07..fc19afb4e93 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart @@ -78,7 +78,7 @@ class UserApi { Future createUser(User user) async { final response = await createUserWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -141,7 +141,7 @@ class UserApi { Future createUsersWithArrayInput(List user) async { final response = await createUsersWithArrayInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -204,7 +204,7 @@ class UserApi { Future createUsersWithListInput(List user) async { final response = await createUsersWithListInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -272,7 +272,7 @@ class UserApi { Future deleteUser(String username) async { final response = await deleteUserWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -336,13 +336,13 @@ class UserApi { Future getUserByName(String username) async { final response = await getUserByNameWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User; } return Future.value(null); } @@ -418,13 +418,13 @@ class UserApi { Future loginUser(String username, String password) async { final response = await loginUserWithHttpInfo(username, password); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } return Future.value(null); } @@ -473,7 +473,7 @@ class UserApi { Future logoutUser() async { final response = await logoutUserWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -550,7 +550,7 @@ class UserApi { Future updateUser(String username, User user) async { final response = await updateUserWithHttpInfo(username, user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart index 87a7a36d470..c847d27f60b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart @@ -44,17 +44,16 @@ class ApiClient { Map get defaultHeaderMap => _defaultHeaderMap; - /// returns an unmodifiable view of the authentications, since none should be added - /// nor deleted - Map get authentications => - Map.unmodifiable(_authentications); + /// Returns an unmodifiable [Map] of the authentications, since none should be added + /// or deleted. + Map get authentications => Map.unmodifiable(_authentications); T getAuthentication(String name) { final authentication = _authentications[name]; return authentication is T ? authentication : null; } - // We don’t use a Map for queryParams. + // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( String path, @@ -85,7 +84,7 @@ class ApiClient { } try { - // Special case for uploading a single file which isn’t a 'multipart/form-data'. + // Special case for uploading a single file which isn't a 'multipart/form-data'. if ( body is MultipartFile && (nullableContentType == null || !nullableContentType.toLowerCase().startsWith('multipart/form-data')) @@ -115,7 +114,7 @@ class ApiClient { final msgBody = nullableContentType == 'application/x-www-form-urlencoded' ? formParams - : serialize(body); + : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; switch(method) { @@ -141,7 +140,44 @@ class ApiClient { throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',); } - dynamic _deserialize(dynamic value, String targetType, {bool growable}) { + Future deserializeAsync(String json, String targetType, {bool growable}) async => + // ignore: deprecated_member_use_from_same_package + deserialize(json, targetType, growable: growable); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.') + dynamic deserialize(String json, String targetType, {bool growable}) { + // Remove all spaces. Necessary for regular expressions as well. + targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? json + : _deserialize(jsonDecode(json), targetType, growable: growable == true); + } + + // ignore: deprecated_member_use_from_same_package + Future serializeAsync(Object value) async => serialize(value); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') + String serialize(Object value) => value == null ? '' : json.encode(value); + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth( + List authNames, + List queryParams, + Map headerParams, + ) { + authNames.forEach((authName) { + final auth = _authentications[authName]; + if (auth == null) { + throw ArgumentError('Authentication undefined: $authName'); + } + auth.applyToParams(queryParams, headerParams); + }); + } + + static dynamic _deserialize(dynamic value, String targetType, {bool growable}) { try { switch (targetType) { case 'String': @@ -172,56 +208,65 @@ class ApiClient { default: Match match; if (value is List && (match = _regList.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) - .toList(growable: true == growable); + .map((v) => _deserialize(v, targetType, growable: growable)) + .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) + .map((v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return Map.fromIterables( value.keys, - value.values.map((v) => _deserialize(v, newTargetType, growable: growable)), + value.values.map((v) => _deserialize(v, targetType, growable: growable)), ); } break; } - } on Exception catch (e, stack) { - throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,); + } catch (error, trace) { + throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); } - - dynamic deserialize(String json, String targetType, {bool growable}) { - // Remove all spaces. Necessary for reg expressions as well. - targetType = targetType.replaceAll(' ', ''); - - return targetType == 'String' - ? json - : _deserialize(jsonDecode(json), targetType, growable: true == growable); - } - - String serialize(Object obj) => obj == null ? '' : json.encode(obj); - - /// Update query and header parameters based on authentication settings. - /// @param authNames The authentications to apply - void _updateParamsForAuth( - List authNames, - List queryParams, - Map headerParams, - ) { - authNames.forEach((authName) { - final auth = _authentications[authName]; - if (auth == null) { - throw ArgumentError('Authentication undefined: $authName'); - } - auth.applyToParams(queryParams, headerParams); - }); - } } + +/// Primarily intended for use in an isolate. +class DeserializationMessage { + const DeserializationMessage({ + @required this.json, + @required this.targetType, + this.growable, + }); + + /// The JSON value to deserialize. + final String json; + + /// Target type to deserialize to. + final String targetType; + + /// Whether to make deserialized lists or maps growable. + final bool growable; +} + +/// Primarily intended for use in an isolate. +Future deserializeAsync(DeserializationMessage message) async { + // Remove all spaces. Necessary for regular expressions as well. + final targetType = message.targetType.replaceAll(' ', ''); + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? message.json + : ApiClient._deserialize( + jsonDecode(message.json), + targetType, + growable: message.growable == true, + ); +} + +/// Primarily intended for use in an isolate. +Future serializeAsync(Object value) async => value == null ? '' : json.encode(value); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart index 141f4a7f5b4..4135dcf95b2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart @@ -63,7 +63,7 @@ String parameterToString(dynamic value) { /// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json' /// content type. Otherwise, returns the decoded body as decoded by dart:http package. -String _decodeBodyBytes(Response response) { +Future _decodeBodyBytes(Response response) async { final contentType = response.headers['content-type']; return contentType != null && contentType.toLowerCase().startsWith('application/json') ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart index d68dcf2e279..b0b0e5977da 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart @@ -15,7 +15,6 @@ import 'dart:io'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; - import 'package:meta/meta.dart'; part 'api_client.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart index 4dbc722ac17..c297f77a8a3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -78,13 +78,13 @@ class AnotherFakeApi { Future call123testSpecialTags(ModelClient modelClient) async { final response = await call123testSpecialTagsWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart index a75bdc33448..1185af2521c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart @@ -56,13 +56,13 @@ class DefaultApi { Future fooGet() async { final response = await fooGetWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'InlineResponseDefault') as InlineResponseDefault; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'InlineResponseDefault',) as InlineResponseDefault; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index d25c1bcd4a5..20db8f0c9b0 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -59,13 +59,13 @@ class FakeApi { Future fakeHealthGet() async { final response = await fakeHealthGetWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'HealthCheckResult') as HealthCheckResult; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'HealthCheckResult',) as HealthCheckResult; } return Future.value(null); } @@ -149,7 +149,7 @@ class FakeApi { Future fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async { final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -209,13 +209,13 @@ class FakeApi { Future fakeOuterBooleanSerialize({ bool body }) async { final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'bool') as bool; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'bool',) as bool; } return Future.value(null); } @@ -276,13 +276,13 @@ class FakeApi { Future fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async { final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'OuterComposite') as OuterComposite; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterComposite',) as OuterComposite; } return Future.value(null); } @@ -343,13 +343,13 @@ class FakeApi { Future fakeOuterNumberSerialize({ num body }) async { final response = await fakeOuterNumberSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'num') as num; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'num',) as num; } return Future.value(null); } @@ -410,13 +410,13 @@ class FakeApi { Future fakeOuterStringSerialize({ String body }) async { final response = await fakeOuterStringSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } return Future.value(null); } @@ -480,13 +480,13 @@ class FakeApi { Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'OuterObjectWithEnumProperty') as OuterObjectWithEnumProperty; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterObjectWithEnumProperty',) as OuterObjectWithEnumProperty; } return Future.value(null); } @@ -548,7 +548,7 @@ class FakeApi { Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async { final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -613,7 +613,7 @@ class FakeApi { Future testBodyWithQueryParams(String query, User user) async { final response = await testBodyWithQueryParamsWithHttpInfo(query, user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -680,13 +680,13 @@ class FakeApi { Future testClientModel(ModelClient modelClient) async { final response = await testClientModelWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } return Future.value(null); } @@ -937,7 +937,7 @@ class FakeApi { Future testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async { final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1077,7 +1077,7 @@ class FakeApi { Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1194,7 +1194,7 @@ class FakeApi { Future testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async { final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1257,7 +1257,7 @@ class FakeApi { Future testInlineAdditionalProperties(Map requestBody) async { final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1343,7 +1343,7 @@ class FakeApi { Future testJsonFormData(String param, String param2) async { final response = await testJsonFormDataWithHttpInfo(param, param2); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1438,7 +1438,7 @@ class FakeApi { Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context) async { final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index 0455f4c68f0..f7e337dbee5 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -78,13 +78,13 @@ class FakeClassnameTags123Api { Future testClassname(ModelClient modelClient) async { final response = await testClassnameWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart index eacebcceace..af2215c4db7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart @@ -74,7 +74,7 @@ class PetApi { Future addPet(Pet pet) async { final response = await addPetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -146,7 +146,7 @@ class PetApi { Future deletePet(int petId, { String apiKey }) async { final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -215,13 +215,13 @@ class PetApi { Future> findPetsByStatus(List status) async { final response = await findPetsByStatusWithHttpInfo(status); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'List') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) .cast() .toList(growable: false); } @@ -293,13 +293,13 @@ class PetApi { Future> findPetsByTags(Set tags) async { final response = await findPetsByTagsWithHttpInfo(tags); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return (apiClient.deserialize(_decodeBodyBytes(response), 'Set') as List) + return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Set') as List) .cast() .toSet(); } @@ -370,13 +370,13 @@ class PetApi { Future getPetById(int petId) async { final response = await getPetByIdWithHttpInfo(petId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } return Future.value(null); } @@ -440,7 +440,7 @@ class PetApi { Future updatePet(Pet pet) async { final response = await updatePetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -530,7 +530,7 @@ class PetApi { Future updatePetWithForm(int petId, { String name, String status }) async { final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -618,13 +618,13 @@ class PetApi { Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } return Future.value(null); } @@ -716,13 +716,13 @@ class PetApi { Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart index 91d115d44c8..ea459d16052 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart @@ -79,7 +79,7 @@ class StoreApi { Future deleteOrder(String orderId) async { final response = await deleteOrderWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -131,13 +131,13 @@ class StoreApi { Future> getInventory() async { final response = await getInventoryWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return Map.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map')); + return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),); } return Future>.value(null); } @@ -206,13 +206,13 @@ class StoreApi { Future getOrderById(int orderId) async { final response = await getOrderByIdWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } @@ -276,13 +276,13 @@ class StoreApi { Future placeOrder(Order order) async { final response = await placeOrderWithHttpInfo(order); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } return Future.value(null); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart index 05ce7f9dec1..0a2c54c75fe 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart @@ -78,7 +78,7 @@ class UserApi { Future createUser(User user) async { final response = await createUserWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -141,7 +141,7 @@ class UserApi { Future createUsersWithArrayInput(List user) async { final response = await createUsersWithArrayInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -204,7 +204,7 @@ class UserApi { Future createUsersWithListInput(List user) async { final response = await createUsersWithListInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -272,7 +272,7 @@ class UserApi { Future deleteUser(String username) async { final response = await deleteUserWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -336,13 +336,13 @@ class UserApi { Future getUserByName(String username) async { final response = await getUserByNameWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User; } return Future.value(null); } @@ -418,13 +418,13 @@ class UserApi { Future loginUser(String username, String password) async { final response = await loginUserWithHttpInfo(username, password); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // FormatException when trying to decode an empty string. if (response.body != null && response.statusCode != HttpStatus.noContent) { - return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String; + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } return Future.value(null); } @@ -473,7 +473,7 @@ class UserApi { Future logoutUser() async { final response = await logoutUserWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -550,7 +550,7 @@ class UserApi { Future updateUser(String username, User user) async { final response = await updateUserWithHttpInfo(username, user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart index 83da5a1e482..83cad2d3ded 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart @@ -47,17 +47,16 @@ class ApiClient { Map get defaultHeaderMap => _defaultHeaderMap; - /// returns an unmodifiable view of the authentications, since none should be added - /// nor deleted - Map get authentications => - Map.unmodifiable(_authentications); + /// Returns an unmodifiable [Map] of the authentications, since none should be added + /// or deleted. + Map get authentications => Map.unmodifiable(_authentications); T getAuthentication(String name) { final authentication = _authentications[name]; return authentication is T ? authentication : null; } - // We don’t use a Map for queryParams. + // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( String path, @@ -88,7 +87,7 @@ class ApiClient { } try { - // Special case for uploading a single file which isn’t a 'multipart/form-data'. + // Special case for uploading a single file which isn't a 'multipart/form-data'. if ( body is MultipartFile && (nullableContentType == null || !nullableContentType.toLowerCase().startsWith('multipart/form-data')) @@ -118,7 +117,7 @@ class ApiClient { final msgBody = nullableContentType == 'application/x-www-form-urlencoded' ? formParams - : serialize(body); + : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; switch(method) { @@ -144,7 +143,44 @@ class ApiClient { throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',); } - dynamic _deserialize(dynamic value, String targetType, {bool growable}) { + Future deserializeAsync(String json, String targetType, {bool growable}) async => + // ignore: deprecated_member_use_from_same_package + deserialize(json, targetType, growable: growable); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.') + dynamic deserialize(String json, String targetType, {bool growable}) { + // Remove all spaces. Necessary for regular expressions as well. + targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? json + : _deserialize(jsonDecode(json), targetType, growable: growable == true); + } + + // ignore: deprecated_member_use_from_same_package + Future serializeAsync(Object value) async => serialize(value); + + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') + String serialize(Object value) => value == null ? '' : json.encode(value); + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth( + List authNames, + List queryParams, + Map headerParams, + ) { + authNames.forEach((authName) { + final auth = _authentications[authName]; + if (auth == null) { + throw ArgumentError('Authentication undefined: $authName'); + } + auth.applyToParams(queryParams, headerParams); + }); + } + + static dynamic _deserialize(dynamic value, String targetType, {bool growable}) { try { switch (targetType) { case 'String': @@ -256,56 +292,65 @@ class ApiClient { default: Match match; if (value is List && (match = _regList.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) - .toList(growable: true == growable); + .map((v) => _deserialize(v, targetType, growable: growable)) + .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, newTargetType, growable: growable)) + .map((v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { - final newTargetType = match[1]; + targetType = match[1]; // ignore: parameter_assignments return Map.fromIterables( value.keys, - value.values.map((v) => _deserialize(v, newTargetType, growable: growable)), + value.values.map((v) => _deserialize(v, targetType, growable: growable)), ); } break; } - } on Exception catch (e, stack) { - throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,); + } catch (error, trace) { + throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); } - - dynamic deserialize(String json, String targetType, {bool growable}) { - // Remove all spaces. Necessary for reg expressions as well. - targetType = targetType.replaceAll(' ', ''); - - return targetType == 'String' - ? json - : _deserialize(jsonDecode(json), targetType, growable: true == growable); - } - - String serialize(Object obj) => obj == null ? '' : json.encode(obj); - - /// Update query and header parameters based on authentication settings. - /// @param authNames The authentications to apply - void _updateParamsForAuth( - List authNames, - List queryParams, - Map headerParams, - ) { - authNames.forEach((authName) { - final auth = _authentications[authName]; - if (auth == null) { - throw ArgumentError('Authentication undefined: $authName'); - } - auth.applyToParams(queryParams, headerParams); - }); - } } + +/// Primarily intended for use in an isolate. +class DeserializationMessage { + const DeserializationMessage({ + @required this.json, + @required this.targetType, + this.growable, + }); + + /// The JSON value to deserialize. + final String json; + + /// Target type to deserialize to. + final String targetType; + + /// Whether to make deserialized lists or maps growable. + final bool growable; +} + +/// Primarily intended for use in an isolate. +Future deserializeAsync(DeserializationMessage message) async { + // Remove all spaces. Necessary for regular expressions as well. + final targetType = message.targetType.replaceAll(' ', ''); + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? message.json + : ApiClient._deserialize( + jsonDecode(message.json), + targetType, + growable: message.growable == true, + ); +} + +/// Primarily intended for use in an isolate. +Future serializeAsync(Object value) async => value == null ? '' : json.encode(value); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart index ececff49c4c..96214037944 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart @@ -78,7 +78,7 @@ String parameterToString(dynamic value) { /// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json' /// content type. Otherwise, returns the decoded body as decoded by dart:http package. -String _decodeBodyBytes(Response response) { +Future _decodeBodyBytes(Response response) async { final contentType = response.headers['content-type']; return contentType != null && contentType.toLowerCase().startsWith('application/json') ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart index 9fdfdb55fb8..2803013466c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart @@ -15,9 +15,8 @@ import 'dart:io'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; - -import 'package:meta/meta.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:meta/meta.dart'; part 'api_client.dart'; part 'api_helper.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart index 29c7103abd3..b712431a035 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart @@ -78,7 +78,7 @@ class AnotherFakeApi { Future call123testSpecialTags(ModelClient modelClient) async { final response = await call123testSpecialTagsWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart index 6295891cd3c..779bdec8b3a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart @@ -56,7 +56,7 @@ class DefaultApi { Future fooGet() async { final response = await fooGetWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart index 21c888fa588..edcd08cfa4a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart @@ -59,7 +59,7 @@ class FakeApi { Future fakeHealthGet() async { final response = await fakeHealthGetWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -150,7 +150,7 @@ class FakeApi { Future fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async { final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -210,7 +210,7 @@ class FakeApi { Future fakeOuterBooleanSerialize({ bool body }) async { final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -278,7 +278,7 @@ class FakeApi { Future fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async { final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -346,7 +346,7 @@ class FakeApi { Future fakeOuterNumberSerialize({ num body }) async { final response = await fakeOuterNumberSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -414,7 +414,7 @@ class FakeApi { Future fakeOuterStringSerialize({ String body }) async { final response = await fakeOuterStringSerializeWithHttpInfo( body: body ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -485,7 +485,7 @@ class FakeApi { Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -554,7 +554,7 @@ class FakeApi { Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async { final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -619,7 +619,7 @@ class FakeApi { Future testBodyWithQueryParams(String query, User user) async { final response = await testBodyWithQueryParamsWithHttpInfo(query, user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -686,7 +686,7 @@ class FakeApi { Future testClientModel(ModelClient modelClient) async { final response = await testClientModelWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -944,7 +944,7 @@ class FakeApi { Future testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async { final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1084,7 +1084,7 @@ class FakeApi { Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1201,7 +1201,7 @@ class FakeApi { Future testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async { final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1264,7 +1264,7 @@ class FakeApi { Future testInlineAdditionalProperties(Map requestBody) async { final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1350,7 +1350,7 @@ class FakeApi { Future testJsonFormData(String param, String param2) async { final response = await testJsonFormDataWithHttpInfo(param, param2); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -1445,7 +1445,7 @@ class FakeApi { Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context) async { final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart index dc0b394f8fb..49f4ce7cde2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -78,7 +78,7 @@ class FakeClassnameTags123Api { Future testClassname(ModelClient modelClient) async { final response = await testClassnameWithHttpInfo(modelClient); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart index 6c43311b2e8..cd2a65ab939 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart @@ -74,7 +74,7 @@ class PetApi { Future addPet(Pet pet) async { final response = await addPetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -146,7 +146,7 @@ class PetApi { Future deletePet(int petId, { String apiKey }) async { final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -215,7 +215,7 @@ class PetApi { Future> findPetsByStatus(List status) async { final response = await findPetsByStatusWithHttpInfo(status); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -294,7 +294,7 @@ class PetApi { Future> findPetsByTags(Set tags) async { final response = await findPetsByTagsWithHttpInfo(tags); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -372,7 +372,7 @@ class PetApi { Future getPetById(int petId) async { final response = await getPetByIdWithHttpInfo(petId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -443,7 +443,7 @@ class PetApi { Future updatePet(Pet pet) async { final response = await updatePetWithHttpInfo(pet); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -533,7 +533,7 @@ class PetApi { Future updatePetWithForm(int petId, { String name, String status }) async { final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -621,7 +621,7 @@ class PetApi { Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -720,7 +720,7 @@ class PetApi { Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata ); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart index dd5c2db3528..9e262c18b98 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart @@ -79,7 +79,7 @@ class StoreApi { Future deleteOrder(String orderId) async { final response = await deleteOrderWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -131,7 +131,7 @@ class StoreApi { Future> getInventory() async { final response = await getInventoryWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -207,7 +207,7 @@ class StoreApi { Future getOrderById(int orderId) async { final response = await getOrderByIdWithHttpInfo(orderId); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -278,7 +278,7 @@ class StoreApi { Future placeOrder(Order order) async { final response = await placeOrderWithHttpInfo(order); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart index ba21021c9dd..3291afc2670 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart @@ -78,7 +78,7 @@ class UserApi { Future createUser(User user) async { final response = await createUserWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -141,7 +141,7 @@ class UserApi { Future createUsersWithArrayInput(List user) async { final response = await createUsersWithArrayInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -204,7 +204,7 @@ class UserApi { Future createUsersWithListInput(List user) async { final response = await createUsersWithListInputWithHttpInfo(user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -272,7 +272,7 @@ class UserApi { Future deleteUser(String username) async { final response = await deleteUserWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -336,7 +336,7 @@ class UserApi { Future getUserByName(String username) async { final response = await getUserByNameWithHttpInfo(username); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -419,7 +419,7 @@ class UserApi { Future loginUser(String username, String password) async { final response = await loginUserWithHttpInfo(username, password); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } // When a remote server returns no body with a status of 204, we shall not decode it. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" @@ -475,7 +475,7 @@ class UserApi { Future logoutUser() async { final response = await logoutUserWithHttpInfo(); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } @@ -552,7 +552,7 @@ class UserApi { Future updateUser(String username, User user) async { final response = await updateUserWithHttpInfo(username, user); if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, _decodeBodyBytes(response)); + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart index 593d552210b..f54d8cad38d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart @@ -47,17 +47,16 @@ class ApiClient { Map get defaultHeaderMap => _defaultHeaderMap; - /// returns an unmodifiable view of the authentications, since none should be added - /// nor deleted - Map get authentications => - Map.unmodifiable(_authentications); + /// Returns an unmodifiable [Map] of the authentications, since none should be added + /// or deleted. + Map get authentications => Map.unmodifiable(_authentications); T getAuthentication(String name) { final authentication = _authentications[name]; return authentication is T ? authentication : null; } - // We don’t use a Map for queryParams. + // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( String path, @@ -88,7 +87,7 @@ class ApiClient { } try { - // Special case for uploading a single file which isn’t a 'multipart/form-data'. + // Special case for uploading a single file which isn't a 'multipart/form-data'. if ( body is MultipartFile && (nullableContentType == null || !nullableContentType.toLowerCase().startsWith('multipart/form-data')) @@ -118,7 +117,7 @@ class ApiClient { final msgBody = nullableContentType == 'application/x-www-form-urlencoded' ? formParams - : serialize(body); + : await serializeAsync(body); final nullableHeaderParams = headerParams.isEmpty ? null : headerParams; switch(method) { @@ -144,8 +143,11 @@ class ApiClient { throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',); } + // ignore: deprecated_member_use_from_same_package + Future serializeAsync(Object value) async => serialize(value); - String serialize(Object obj) => obj == null ? '' : json.encode(obj); + @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') + String serialize(Object value) => value == null ? '' : json.encode(value); /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply @@ -162,4 +164,8 @@ class ApiClient { auth.applyToParams(queryParams, headerParams); }); } + } + +/// Primarily intended for use in an isolate. +Future serializeAsync(Object value) async => value == null ? '' : json.encode(value); diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart index f9904f5ec71..51db433eb30 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart @@ -78,7 +78,7 @@ String parameterToString(dynamic value) { /// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json' /// content type. Otherwise, returns the decoded body as decoded by dart:http package. -String _decodeBodyBytes(Response response) { +Future _decodeBodyBytes(Response response) async { final contentType = response.headers['content-type']; return contentType != null && contentType.toLowerCase().startsWith('application/json') ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) From 59089feb64cc58487f5e056269dd070092bc5921 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 1 Apr 2021 09:19:50 +0800 Subject: [PATCH 08/99] update samples --- .../.openapi-generator/FILES | 1 - .../.openapi-generator/VERSION | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES index 94732e37243..a5adeaaddc6 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/FILES @@ -150,7 +150,6 @@ petstore_api/model/user.py petstore_api/model/xml_item.py petstore_api/model_utils.py petstore_api/models/__init__.py -petstore_api/models/__init__.py petstore_api/rest.py requirements.txt setup.cfg diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION index d509cc92aa8..6555596f931 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/.openapi-generator/VERSION @@ -1 +1 @@ -5.1.1-SNAPSHOT \ No newline at end of file +5.2.0-SNAPSHOT \ No newline at end of file From b335ba834f07122bdee48f2999d3c769186b31bd Mon Sep 17 00:00:00 2001 From: de1mos Date: Thu, 1 Apr 2021 08:47:11 +0700 Subject: [PATCH 09/99] fix #7325 kotlin-spring fix reactive delegate pattern combination (#8867) * #7325 kotlin-spring remove exchange field from reactive delegate pattern * #7325 remove examples from kotlin-spring reactive delegate and add missing import * #7325 add test assertions * fix swagger spec in test --- .../kotlin-spring/apiDelegate.mustache | 3 +- .../kotlin-spring/apiInterface.mustache | 2 +- .../kotlin-spring/methodBody.mustache | 5 ++ .../spring/KotlinSpringServerCodegenTest.java | 60 +++++++++++++++++-- ...325-use-delegate-reactive-tags-kotlin.yaml | 35 +++++++++++ 5 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/kotlin/issue7325-use-delegate-reactive-tags-kotlin.yaml diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache index d45f9f79f2e..bbf57f85b7b 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache @@ -8,6 +8,7 @@ import org.springframework.http.ResponseEntity import org.springframework.web.context.request.NativeWebRequest import org.springframework.core.io.Resource {{#reactive}} +import kotlinx.coroutines.flow.Flow import org.springframework.web.server.ServerWebExchange import reactor.core.publisher.Flux import reactor.core.publisher.Mono @@ -32,7 +33,7 @@ interface {{classname}}Delegate { /** * @see {{classname}}#{{operationId}} */ - fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{>optionalDataType}}{{/isFile}}{{#isFile}}Resource?{{/isFile}}{{^-last}}, + {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{>optionalDataType}}{{/isFile}}{{#isFile}}Resource?{{/isFile}}{{^-last}}, {{/-last}}{{/allParams}}): {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} { {{>methodBody}} } diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache index bc224b50080..5e9b3888c8d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache @@ -83,7 +83,7 @@ interface {{classname}} { return {{>returnValue}} {{/isDelegate}} {{#isDelegate}} - return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}); + return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); {{/isDelegate}} } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/methodBody.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/methodBody.mustache index 69a9fd42d93..3e3b63e9ab0 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/methodBody.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/methodBody.mustache @@ -1,3 +1,4 @@ +{{^reactive}} {{#examples}} {{#-first}} {{#async}} @@ -21,3 +22,7 @@ return CompletableFuture.supplyAsync(()-> { {{^examples}} return {{#async}}CompletableFuture.completedFuture({{/async}}ResponseEntity({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}) {{/examples}} +{{/reactive}} +{{#reactive}} +return ResponseEntity({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}) +{{/reactive}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index b77afc858f9..dc3bceaa435 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -1,9 +1,14 @@ package org.openapitools.codegen.kotlin.spring; import com.google.common.collect.testing.Helpers; - +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.servers.Server; import org.apache.commons.io.FileUtils; -import org.openapitools.codegen.*; +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.DefaultGenerator; +import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.kotlin.KotlinTestUtils; import org.openapitools.codegen.languages.KotlinSpringServerCodegen; import org.testng.Assert; @@ -11,12 +16,12 @@ import org.testng.annotations.Test; import java.io.File; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Collections; import java.util.List; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.servers.Server; +import static org.openapitools.codegen.TestUtils.assertFileContains; +import static org.openapitools.codegen.TestUtils.assertFileNotContains; public class KotlinSpringServerCodegenTest { @@ -203,4 +208,49 @@ public class KotlinSpringServerCodegenTest { new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt") ); } + + @Test(description = "test delegate reactive with tags") + public void delegateReactiveWithTags() throws Exception { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); //may be move to /build + KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true); + codegen.additionalProperties().put(KotlinSpringServerCodegen.REACTIVE, true); + codegen.additionalProperties().put(KotlinSpringServerCodegen.USE_TAGS, true); + + List files = new DefaultGenerator() + .opts( + new ClientOptInput() + .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue7325-use-delegate-reactive-tags-kotlin.yaml")) + .config(codegen) + ) + .generate(); + + Helpers.assertContainsAllOf(files, + new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"), + new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiController.kt"), + new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"), + new File(output, "src/main/kotlin/org/openapitools/api/TestV2Api.kt"), + new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiController.kt"), + new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt") + ); + + assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1Api.kt"), + "suspend fun"); + assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1Api.kt"), + "exchange"); + assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"), + "suspend fun"); + assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"), + "ApiUtil"); + + assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2Api.kt"), + "import kotlinx.coroutines.flow.Flow", "ResponseEntity>"); + assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2Api.kt"), + "exchange"); + assertFileContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"), + "import kotlinx.coroutines.flow.Flow"); + assertFileNotContains(Paths.get(output + "/src/main/kotlin/org/openapitools/api/TestV2ApiDelegate.kt"), + "suspend fun", "ApiUtil"); + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/kotlin/issue7325-use-delegate-reactive-tags-kotlin.yaml b/modules/openapi-generator/src/test/resources/3_0/kotlin/issue7325-use-delegate-reactive-tags-kotlin.yaml new file mode 100644 index 00000000000..3a14311e1ca --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/kotlin/issue7325-use-delegate-reactive-tags-kotlin.yaml @@ -0,0 +1,35 @@ +openapi: "3.0.1" +info: + title: test + version: "1.0" + +paths: + + /api/v1/test/{id}: + get: + tags: [Test v1] + operationId: test1 + parameters: + - name: id + in: path + schema: + type: string + responses: + 200: + description: OK + + /api/v2/test: + get: + tags: [Test v2] + operationId: test2 + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + type: string + + From 57e44e173f99c1463bfb62749c8fc14a10639ae9 Mon Sep 17 00:00:00 2001 From: cal Date: Thu, 1 Apr 2021 05:32:10 +0200 Subject: [PATCH 10/99] [cleanup] erefactor/EclipseJdt - Evaluate without null check (#9134) EclipseJdt cleanup 'EvaluateNullable' applied by erefactor. For EclipseJdt see https://www.eclipse.org/eclipse/news/4.19/jdt.php For erefactor see https://github.com/cal101/erefactor --- .../codegen/languages/PhpSymfonyServerCodegen.java | 2 +- .../org/openapitools/codegen/languages/RustServerCodegen.java | 4 ++-- .../org/openapitools/codegen/languages/Swift4Codegen.java | 4 ++-- .../openapitools/codegen/languages/Swift5ClientCodegen.java | 4 ++-- .../codegen/languages/TypeScriptAngularClientCodegen.java | 2 +- .../codegen/languages/TypeScriptInversifyClientCodegen.java | 2 +- .../codegen/languages/TypeScriptNestjsClientCodegen.java | 2 +- .../codegen/languages/TypeScriptNodeClientCodegen.java | 2 +- .../codegen/languages/TypeScriptRxjsClientCodegen.java | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java index 9d468195f85..bfc5a4593b9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java @@ -429,7 +429,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg // Create a variable to display the correct return type in comments for interfaces if (op.returnType != null) { op.vendorExtensions.put("x-comment-type", op.returnType); - if (op.returnContainer != null && "array".equals(op.returnContainer)) { + if ("array".equals(op.returnContainer)) { op.vendorExtensions.put("x-comment-type", op.returnType + "[]"); } } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index 5ff03773da1..a47e86573fb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -1560,12 +1560,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig { LOGGER.trace("Post processing model: {}", cm); - if (cm.dataType != null && "object".equals(cm.dataType)) { + if ("object".equals(cm.dataType)) { // Object isn't a sensible default. Instead, we set it to // 'null'. This ensures that we treat this model as a struct // with multiple parameters. cm.dataType = null; - } else if (cm.dataType != null && "map".equals(cm.dataType)) { + } else if ("map".equals(cm.dataType)) { if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) { // We don't yet support `additionalProperties` that also have // properties. If we see variables, we ignore the diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java index e5724a3c7e8..0133cfb3c17 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java @@ -534,12 +534,12 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig { @Override public boolean isDataTypeFile(String dataType) { - return dataType != null && "URL".equals(dataType); + return "URL".equals(dataType); } @Override public boolean isDataTypeBinary(final String dataType) { - return dataType != null && "Data".equals(dataType); + return "Data".equals(dataType); } /** diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java index a5d71b4d302..5d563656b58 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java @@ -546,12 +546,12 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig @Override public boolean isDataTypeFile(String dataType) { - return dataType != null && "URL".equals(dataType); + return "URL".equals(dataType); } @Override public boolean isDataTypeBinary(final String dataType) { - return dataType != null && "Data".equals(dataType); + return "Data".equals(dataType); } /** diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java index 77bf353a41a..e91ddecda38 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java @@ -384,7 +384,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode @Override public boolean isDataTypeFile(final String dataType) { - return dataType != null && "Blob".equals(dataType); + return "Blob".equals(dataType); } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java index 4b3daba3f85..6de4f086413 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java @@ -141,7 +141,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo @Override public boolean isDataTypeFile(final String dataType) { - return dataType != null && "Blob".equals(dataType); + return "Blob".equals(dataType); } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java index 4e5e6c903ce..771e66db0a4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java @@ -216,7 +216,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg @Override public boolean isDataTypeFile(final String dataType) { - return dataType != null && "Blob".equals(dataType); + return "Blob".equals(dataType); } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java index 9ff6f444c57..613b9da70f2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java @@ -82,7 +82,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen @Override public boolean isDataTypeFile(final String dataType) { - return dataType != null && "RequestFile".equals(dataType); + return "RequestFile".equals(dataType); } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java index a2f79f519ad..bdecf7febe1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java @@ -98,7 +98,7 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen @Override public boolean isDataTypeFile(final String dataType) { - return dataType != null && "Blob".equals(dataType); + return "Blob".equals(dataType); } @Override From 7bf792a3485b967a2ae74f6b3bb3a337ba47e1bb Mon Sep 17 00:00:00 2001 From: sforst Date: Thu, 1 Apr 2021 10:57:36 +0200 Subject: [PATCH 11/99] [typescript-axios] handle uniqueItems in query and header parameters (#8965) * [typescript-axios] handle uniqueItems in query and header parameters add endpoint /fake/test-unique-paramters to petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml for demonstration * update samples * [typescript-axios] update samples Co-authored-by: William Cheng --- ...odels-for-testing-with-http-signature.yaml | 3 + .../typescript-axios/apiInner.mustache | 15 + ...odels-for-testing-with-http-signature.yaml | 33 + .../.gitignore | 4 + .../.npmignore | 1 + .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 8 + .../.openapi-generator/VERSION | 1 + .../api.ts | 4615 +++++++++++++++++ .../base.ts | 71 + .../common.ts | 138 + .../configuration.ts | 101 + .../git_push.sh | 58 + .../index.ts | 18 + .../client/petstore/go/go-petstore/README.md | 1 + .../petstore/go/go-petstore/api/openapi.yaml | 37 + .../petstore/go/go-petstore/api_fake.go | 144 + .../petstore/go/go-petstore/docs/FakeApi.md | 69 + 18 files changed, 5340 insertions(+) create mode 100644 bin/configs/typescript-axios-with-fake-endpoints-models-for-testing-with-http-signature.yaml create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.gitignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.npmignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/FILES create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/base.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/configuration.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/git_push.sh create mode 100644 samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/index.ts diff --git a/bin/configs/typescript-axios-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/bin/configs/typescript-axios-with-fake-endpoints-models-for-testing-with-http-signature.yaml new file mode 100644 index 00000000000..1cb364d79ea --- /dev/null +++ b/bin/configs/typescript-axios-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -0,0 +1,3 @@ +generatorName: typescript-axios +outputDir: samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache index 71981cf8fca..ddcbbbb86e9 100644 --- a/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache @@ -86,10 +86,20 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur {{#isArray}} if ({{paramName}}) { {{#isCollectionFormatMulti}} + {{#uniqueItems}} + localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}); + {{/uniqueItems}} + {{^uniqueItems}} localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/uniqueItems}} {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} + {{#uniqueItems}} + localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/uniqueItems}} + {{^uniqueItems}} localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/uniqueItems}} {{/isCollectionFormatMulti}} } {{/isArray}} @@ -117,7 +127,12 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur {{#headerParams}} {{#isArray}} if ({{paramName}}) { + {{#uniqueItems}} + let mapped = Array.from({{paramName}}).map(value => ("{{{dataType}}}" !== "Set") ? JSON.stringify(value) : (value || "")); + {{/uniqueItems}} + {{^uniqueItems}} let mapped = {{paramName}}.map(value => ("{{{dataType}}}" !== "Array") ? JSON.stringify(value) : (value || "")); + {{/uniqueItems}} localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); } {{/isArray}} diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 8c5c0fffd02..b1490fa6798 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1044,6 +1044,39 @@ paths: responses: "200": description: Success + /fake/test-unique-paramters: + put: + tags: + - fake + description: To test unique items in header and query parameters + operationId: testUniqueItemsHeaderAndQueryParameterCollectionFormat + parameters: + - name: queryUnique + in: query + required: true + schema: + type: array + uniqueItems: true + items: + type: string + - name: headerUnique + in: header + required: true + schema: + type: array + uniqueItems: true + items: + type: string + responses: + "200": + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + uniqueItems: true '/fake/{petId}/uploadImageWithRequiredFile': post: tags: diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.gitignore b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.gitignore new file mode 100644 index 00000000000..149b5765472 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.npmignore b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.npmignore new file mode 100644 index 00000000000..999d88df693 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/FILES b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/FILES new file mode 100644 index 00000000000..a80cd4f07b0 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/FILES @@ -0,0 +1,8 @@ +.gitignore +.npmignore +api.ts +base.ts +common.ts +configuration.ts +git_push.sh +index.ts diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/VERSION new file mode 100644 index 00000000000..d509cc92aa8 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.1.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts new file mode 100644 index 00000000000..44ad2dc5a0a --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts @@ -0,0 +1,4615 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { Configuration } from './configuration'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; + +/** + * + * @export + * @interface AdditionalPropertiesClass + */ +export interface AdditionalPropertiesClass { + /** + * + * @type {{ [key: string]: string; }} + * @memberof AdditionalPropertiesClass + */ + map_property?: { [key: string]: string; }; + /** + * + * @type {{ [key: string]: { [key: string]: string; }; }} + * @memberof AdditionalPropertiesClass + */ + map_of_map_property?: { [key: string]: { [key: string]: string; }; }; +} +/** + * + * @export + * @interface Animal + */ +export interface Animal { + /** + * + * @type {string} + * @memberof Animal + */ + className: string; + /** + * + * @type {string} + * @memberof Animal + */ + color?: string; +} +/** + * + * @export + * @interface ApiResponse + */ +export interface ApiResponse { + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; +} +/** + * + * @export + * @interface Apple + */ +export interface Apple { + /** + * + * @type {string} + * @memberof Apple + */ + cultivar?: string; +} +/** + * + * @export + * @interface AppleReq + */ +export interface AppleReq { + /** + * + * @type {string} + * @memberof AppleReq + */ + cultivar: string; + /** + * + * @type {boolean} + * @memberof AppleReq + */ + mealy?: boolean; +} +/** + * + * @export + * @interface ArrayOfArrayOfNumberOnly + */ +export interface ArrayOfArrayOfNumberOnly { + /** + * + * @type {Array>} + * @memberof ArrayOfArrayOfNumberOnly + */ + ArrayArrayNumber?: Array>; +} +/** + * + * @export + * @interface ArrayOfNumberOnly + */ +export interface ArrayOfNumberOnly { + /** + * + * @type {Array} + * @memberof ArrayOfNumberOnly + */ + ArrayNumber?: Array; +} +/** + * + * @export + * @interface ArrayTest + */ +export interface ArrayTest { + /** + * + * @type {Array} + * @memberof ArrayTest + */ + array_of_string?: Array; + /** + * + * @type {Array>} + * @memberof ArrayTest + */ + array_array_of_integer?: Array>; + /** + * + * @type {Array>} + * @memberof ArrayTest + */ + array_array_of_model?: Array>; +} +/** + * + * @export + * @interface Banana + */ +export interface Banana { + [key: string]: object | any; + + /** + * + * @type {number} + * @memberof Banana + */ + lengthCm?: number; +} +/** + * + * @export + * @interface BananaReq + */ +export interface BananaReq { + /** + * + * @type {number} + * @memberof BananaReq + */ + lengthCm: number; + /** + * + * @type {boolean} + * @memberof BananaReq + */ + sweet?: boolean; +} +/** + * + * @export + * @interface Capitalization + */ +export interface Capitalization { + /** + * + * @type {string} + * @memberof Capitalization + */ + smallCamel?: string; + /** + * + * @type {string} + * @memberof Capitalization + */ + CapitalCamel?: string; + /** + * + * @type {string} + * @memberof Capitalization + */ + small_Snake?: string; + /** + * + * @type {string} + * @memberof Capitalization + */ + Capital_Snake?: string; + /** + * + * @type {string} + * @memberof Capitalization + */ + SCA_ETH_Flow_Points?: string; + /** + * Name of the pet + * @type {string} + * @memberof Capitalization + */ + ATT_NAME?: string; +} +/** + * + * @export + * @interface Cat + */ +export interface Cat extends Animal { + /** + * + * @type {boolean} + * @memberof Cat + */ + declawed?: boolean; +} +/** + * + * @export + * @interface CatAllOf + */ +export interface CatAllOf { + /** + * + * @type {boolean} + * @memberof CatAllOf + */ + declawed?: boolean; +} +/** + * + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name: string; +} +/** + * Model for testing model with \"_class\" property + * @export + * @interface ClassModel + */ +export interface ClassModel { + /** + * + * @type {string} + * @memberof ClassModel + */ + _class?: string; +} +/** + * + * @export + * @interface Client + */ +export interface Client { + /** + * + * @type {string} + * @memberof Client + */ + client?: string; +} +/** + * + * @export + * @interface Dog + */ +export interface Dog extends Animal { + /** + * + * @type {string} + * @memberof Dog + */ + breed?: string; +} +/** + * + * @export + * @interface DogAllOf + */ +export interface DogAllOf { + /** + * + * @type {string} + * @memberof DogAllOf + */ + breed?: string; +} +/** + * + * @export + * @interface EnumArrays + */ +export interface EnumArrays { + /** + * + * @type {string} + * @memberof EnumArrays + */ + just_symbol?: EnumArraysJustSymbolEnum; + /** + * + * @type {Array} + * @memberof EnumArrays + */ + array_enum?: Array; +} + +/** + * @export + * @enum {string} + */ +export enum EnumArraysJustSymbolEnum { + GreaterThanOrEqualTo = '>=', + Dollar = '$' +} +/** + * @export + * @enum {string} + */ +export enum EnumArraysArrayEnumEnum { + Fish = 'fish', + Crab = 'crab' +} + +/** + * + * @export + * @enum {string} + */ +export enum EnumClass { + Abc = '_abc', + Efg = '-efg', + Xyz = '(xyz)' +} + +/** + * + * @export + * @interface EnumTest + */ +export interface EnumTest { + /** + * + * @type {string} + * @memberof EnumTest + */ + enum_string?: EnumTestEnumStringEnum; + /** + * + * @type {string} + * @memberof EnumTest + */ + enum_string_required: EnumTestEnumStringRequiredEnum; + /** + * + * @type {number} + * @memberof EnumTest + */ + enum_integer?: EnumTestEnumIntegerEnum; + /** + * + * @type {number} + * @memberof EnumTest + */ + enum_number?: EnumTestEnumNumberEnum; + /** + * + * @type {OuterEnum} + * @memberof EnumTest + */ + outerEnum?: OuterEnum | null; + /** + * + * @type {OuterEnumInteger} + * @memberof EnumTest + */ + outerEnumInteger?: OuterEnumInteger; + /** + * + * @type {OuterEnumDefaultValue} + * @memberof EnumTest + */ + outerEnumDefaultValue?: OuterEnumDefaultValue; + /** + * + * @type {OuterEnumIntegerDefaultValue} + * @memberof EnumTest + */ + outerEnumIntegerDefaultValue?: OuterEnumIntegerDefaultValue; +} + +/** + * @export + * @enum {string} + */ +export enum EnumTestEnumStringEnum { + Upper = 'UPPER', + Lower = 'lower', + Empty = '' +} +/** + * @export + * @enum {string} + */ +export enum EnumTestEnumStringRequiredEnum { + Upper = 'UPPER', + Lower = 'lower', + Empty = '' +} +/** + * @export + * @enum {string} + */ +export enum EnumTestEnumIntegerEnum { + NUMBER_1 = 1, + NUMBER_MINUS_1 = -1 +} +/** + * @export + * @enum {string} + */ +export enum EnumTestEnumNumberEnum { + NUMBER_1_DOT_1 = 1.1, + NUMBER_MINUS_1_DOT_2 = -1.2 +} + +/** + * + * @export + * @interface FileSchemaTestClass + */ +export interface FileSchemaTestClass { + /** + * + * @type {any} + * @memberof FileSchemaTestClass + */ + file?: any; + /** + * + * @type {Array} + * @memberof FileSchemaTestClass + */ + files?: Array; +} +/** + * + * @export + * @interface Foo + */ +export interface Foo { + /** + * + * @type {string} + * @memberof Foo + */ + bar?: string; +} +/** + * + * @export + * @interface FormatTest + */ +export interface FormatTest { + /** + * + * @type {number} + * @memberof FormatTest + */ + integer?: number; + /** + * + * @type {number} + * @memberof FormatTest + */ + int32?: number; + /** + * + * @type {number} + * @memberof FormatTest + */ + int64?: number; + /** + * + * @type {number} + * @memberof FormatTest + */ + number: number; + /** + * + * @type {number} + * @memberof FormatTest + */ + _float?: number; + /** + * + * @type {number} + * @memberof FormatTest + */ + _double?: number; + /** + * + * @type {string} + * @memberof FormatTest + */ + string?: string; + /** + * + * @type {string} + * @memberof FormatTest + */ + _byte: string; + /** + * + * @type {any} + * @memberof FormatTest + */ + binary?: any; + /** + * + * @type {string} + * @memberof FormatTest + */ + date: string; + /** + * + * @type {string} + * @memberof FormatTest + */ + dateTime?: string; + /** + * + * @type {string} + * @memberof FormatTest + */ + uuid?: string; + /** + * + * @type {string} + * @memberof FormatTest + */ + password: string; + /** + * A string that is a 10 digit number. Can have leading zeros. + * @type {string} + * @memberof FormatTest + */ + pattern_with_digits?: string; + /** + * A string starting with \'image_\' (case insensitive) and one to three digits following i.e. Image_01. + * @type {string} + * @memberof FormatTest + */ + pattern_with_digits_and_delimiter?: string; +} +/** + * @type Fruit + * @export + */ +export type Fruit = Apple | Banana; + +/** + * @type FruitReq + * @export + */ +export type FruitReq = AppleReq | BananaReq; + +/** + * + * @export + * @interface GmFruit + */ +export interface GmFruit { + /** + * + * @type {string} + * @memberof GmFruit + */ + color?: string; + /** + * + * @type {string} + * @memberof GmFruit + */ + cultivar?: string; + /** + * + * @type {number} + * @memberof GmFruit + */ + lengthCm?: number; +} +/** + * + * @export + * @interface HasOnlyReadOnly + */ +export interface HasOnlyReadOnly { + /** + * + * @type {string} + * @memberof HasOnlyReadOnly + */ + bar?: string; + /** + * + * @type {string} + * @memberof HasOnlyReadOnly + */ + foo?: string; +} +/** + * Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + * @export + * @interface HealthCheckResult + */ +export interface HealthCheckResult { + /** + * + * @type {string} + * @memberof HealthCheckResult + */ + NullableMessage?: string | null; +} +/** + * + * @export + * @interface InlineResponseDefault + */ +export interface InlineResponseDefault { + /** + * + * @type {Foo} + * @memberof InlineResponseDefault + */ + string?: Foo; +} +/** + * + * @export + * @interface List + */ +export interface List { + /** + * + * @type {string} + * @memberof List + */ + _123_list?: string; +} +/** + * @type Mammal + * @export + */ +export type Mammal = Whale | Zebra; + +/** + * + * @export + * @interface MapTest + */ +export interface MapTest { + /** + * + * @type {{ [key: string]: { [key: string]: string; }; }} + * @memberof MapTest + */ + map_map_of_string?: { [key: string]: { [key: string]: string; }; }; + /** + * + * @type {{ [key: string]: string; }} + * @memberof MapTest + */ + map_of_enum_string?: { [key: string]: string; }; + /** + * + * @type {{ [key: string]: boolean; }} + * @memberof MapTest + */ + direct_map?: { [key: string]: boolean; }; + /** + * + * @type {{ [key: string]: boolean; }} + * @memberof MapTest + */ + indirect_map?: { [key: string]: boolean; }; +} + +/** + * @export + * @enum {string} + */ +export enum MapTestMapOfEnumStringEnum { + Upper = 'UPPER', + Lower = 'lower' +} + +/** + * + * @export + * @interface MixedPropertiesAndAdditionalPropertiesClass + */ +export interface MixedPropertiesAndAdditionalPropertiesClass { + /** + * + * @type {string} + * @memberof MixedPropertiesAndAdditionalPropertiesClass + */ + uuid?: string; + /** + * + * @type {string} + * @memberof MixedPropertiesAndAdditionalPropertiesClass + */ + dateTime?: string; + /** + * + * @type {{ [key: string]: Animal; }} + * @memberof MixedPropertiesAndAdditionalPropertiesClass + */ + map?: { [key: string]: Animal; }; +} +/** + * Model for testing model name starting with number + * @export + * @interface Model200Response + */ +export interface Model200Response { + /** + * + * @type {number} + * @memberof Model200Response + */ + name?: number; + /** + * + * @type {string} + * @memberof Model200Response + */ + _class?: string; +} +/** + * Must be named `File` for test. + * @export + * @interface ModelFile + */ +export interface ModelFile { + /** + * Test capitalization + * @type {string} + * @memberof ModelFile + */ + sourceURI?: string; +} +/** + * Model for testing model name same as property name + * @export + * @interface Name + */ +export interface Name { + /** + * + * @type {number} + * @memberof Name + */ + name: number; + /** + * + * @type {number} + * @memberof Name + */ + snake_case?: number; + /** + * + * @type {string} + * @memberof Name + */ + property?: string; + /** + * + * @type {number} + * @memberof Name + */ + _123Number?: number; +} +/** + * + * @export + * @interface NullableClass + */ +export interface NullableClass { + [key: string]: object | any; + + /** + * + * @type {number} + * @memberof NullableClass + */ + integer_prop?: number | null; + /** + * + * @type {number} + * @memberof NullableClass + */ + number_prop?: number | null; + /** + * + * @type {boolean} + * @memberof NullableClass + */ + boolean_prop?: boolean | null; + /** + * + * @type {string} + * @memberof NullableClass + */ + string_prop?: string | null; + /** + * + * @type {string} + * @memberof NullableClass + */ + date_prop?: string | null; + /** + * + * @type {string} + * @memberof NullableClass + */ + datetime_prop?: string | null; + /** + * + * @type {Array} + * @memberof NullableClass + */ + array_nullable_prop?: Array | null; + /** + * + * @type {Array} + * @memberof NullableClass + */ + array_and_items_nullable_prop?: Array | null; + /** + * + * @type {Array} + * @memberof NullableClass + */ + array_items_nullable?: Array; + /** + * + * @type {{ [key: string]: object; }} + * @memberof NullableClass + */ + object_nullable_prop?: { [key: string]: object; } | null; + /** + * + * @type {{ [key: string]: object; }} + * @memberof NullableClass + */ + object_and_items_nullable_prop?: { [key: string]: object; } | null; + /** + * + * @type {{ [key: string]: object; }} + * @memberof NullableClass + */ + object_items_nullable?: { [key: string]: object; }; +} +/** + * + * @export + * @interface NumberOnly + */ +export interface NumberOnly { + /** + * + * @type {number} + * @memberof NumberOnly + */ + JustNumber?: number; +} +/** + * + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {string} + * @memberof Order + */ + shipDate?: string; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: OrderStatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @enum {string} + */ +export enum OrderStatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +} + +/** + * + * @export + * @interface OuterComposite + */ +export interface OuterComposite { + /** + * + * @type {number} + * @memberof OuterComposite + */ + my_number?: number; + /** + * + * @type {string} + * @memberof OuterComposite + */ + my_string?: string; + /** + * + * @type {boolean} + * @memberof OuterComposite + */ + my_boolean?: boolean; +} +/** + * + * @export + * @enum {string} + */ +export enum OuterEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +} + +/** + * + * @export + * @enum {string} + */ +export enum OuterEnumDefaultValue { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +} + +/** + * + * @export + * @enum {string} + */ +export enum OuterEnumInteger { + NUMBER_0 = 0, + NUMBER_1 = 1, + NUMBER_2 = 2 +} + +/** + * + * @export + * @enum {string} + */ +export enum OuterEnumIntegerDefaultValue { + NUMBER_0 = 0, + NUMBER_1 = 1, + NUMBER_2 = 2 +} + +/** + * + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: PetStatusEnum; +} + +/** + * @export + * @enum {string} + */ +export enum PetStatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' +} + +/** + * + * @export + * @interface ReadOnlyFirst + */ +export interface ReadOnlyFirst { + /** + * + * @type {string} + * @memberof ReadOnlyFirst + */ + bar?: string; + /** + * + * @type {string} + * @memberof ReadOnlyFirst + */ + baz?: string; +} +/** + * Model for testing reserved words + * @export + * @interface Return + */ +export interface Return { + /** + * + * @type {number} + * @memberof Return + */ + _return?: number; +} +/** + * + * @export + * @interface SpecialModelName + */ +export interface SpecialModelName { + /** + * + * @type {number} + * @memberof SpecialModelName + */ + $special_property_name?: number; +} +/** + * + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} +/** + * + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; + /** + * test code generation for objects Value must be a map of strings to values. It cannot be the \'null\' value. + * @type {object} + * @memberof User + */ + arbitraryObject?: object; + /** + * test code generation for nullable objects. Value must be a map of strings to values or the \'null\' value. + * @type {object} + * @memberof User + */ + arbitraryNullableObject?: object | null; + /** + * test code generation for any type Value can be any type - string, number, boolean, array or object. + * @type {any} + * @memberof User + */ + arbitraryTypeValue?: any | null; + /** + * test code generation for any type Value can be any type - string, number, boolean, array, object or the \'null\' value. + * @type {any} + * @memberof User + */ + arbitraryNullableTypeValue?: any | null; +} +/** + * + * @export + * @interface Whale + */ +export interface Whale { + /** + * + * @type {boolean} + * @memberof Whale + */ + hasBaleen?: boolean; + /** + * + * @type {boolean} + * @memberof Whale + */ + hasTeeth?: boolean; + /** + * + * @type {string} + * @memberof Whale + */ + className: string; +} +/** + * + * @export + * @interface Zebra + */ +export interface Zebra { + /** + * + * @type {string} + * @memberof Zebra + */ + type?: ZebraTypeEnum; + /** + * + * @type {string} + * @memberof Zebra + */ + className: string; +} + +/** + * @export + * @enum {string} + */ +export enum ZebraTypeEnum { + Plains = 'plains', + Mountain = 'mountain', + Grevys = 'grevys' +} + + +/** + * AnotherFakeApi - axios parameter creator + * @export + */ +export const AnotherFakeApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * To test special tags and operation ID starting with number + * @summary To test special tags + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + _123testSpecialTags: async (client: Client, options: any = {}): Promise => { + // verify required parameter 'client' is not null or undefined + assertParamExists('_123testSpecialTags', 'client', client) + const localVarPath = `/another-fake/dummy`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(client, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * AnotherFakeApi - functional programming interface + * @export + */ +export const AnotherFakeApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = AnotherFakeApiAxiosParamCreator(configuration) + return { + /** + * To test special tags and operation ID starting with number + * @summary To test special tags + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async _123testSpecialTags(client: Client, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator._123testSpecialTags(client, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * AnotherFakeApi - factory interface + * @export + */ +export const AnotherFakeApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = AnotherFakeApiFp(configuration) + return { + /** + * To test special tags and operation ID starting with number + * @summary To test special tags + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + _123testSpecialTags(client: Client, options?: any): AxiosPromise { + return localVarFp._123testSpecialTags(client, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * AnotherFakeApi - object-oriented interface + * @export + * @class AnotherFakeApi + * @extends {BaseAPI} + */ +export class AnotherFakeApi extends BaseAPI { + /** + * To test special tags and operation ID starting with number + * @summary To test special tags + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AnotherFakeApi + */ + public _123testSpecialTags(client: Client, options?: any) { + return AnotherFakeApiFp(this.configuration)._123testSpecialTags(client, options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * DefaultApi - axios parameter creator + * @export + */ +export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fooGet: async (options: any = {}): Promise => { + const localVarPath = `/foo`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DefaultApi - functional programming interface + * @export + */ +export const DefaultApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration) + return { + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fooGet(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fooGet(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * DefaultApi - factory interface + * @export + */ +export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = DefaultApiFp(configuration) + return { + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fooGet(options?: any): AxiosPromise { + return localVarFp.fooGet(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +export class DefaultApi extends BaseAPI { + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public fooGet(options?: any) { + return DefaultApiFp(this.configuration).fooGet(options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * FakeApi - axios parameter creator + * @export + */ +export const FakeApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Health check endpoint + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeHealthGet: async (options: any = {}): Promise => { + const localVarPath = `/fake/health`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Test serialization of outer boolean types + * @param {boolean} [body] Input boolean as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterBooleanSerialize: async (body?: boolean, options: any = {}): Promise => { + const localVarPath = `/fake/outer/boolean`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Test serialization of object with outer number type + * @param {OuterComposite} [outerComposite] Input composite as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterCompositeSerialize: async (outerComposite?: OuterComposite, options: any = {}): Promise => { + const localVarPath = `/fake/outer/composite`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(outerComposite, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Test serialization of outer number types + * @param {number} [body] Input number as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterNumberSerialize: async (body?: number, options: any = {}): Promise => { + const localVarPath = `/fake/outer/number`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Test serialization of outer string types + * @param {string} [body] Input string as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterStringSerialize: async (body?: string, options: any = {}): Promise => { + const localVarPath = `/fake/outer/string`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * For this test, the body for this request much reference a schema named `File`. + * @param {FileSchemaTestClass} fileSchemaTestClass + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testBodyWithFileSchema: async (fileSchemaTestClass: FileSchemaTestClass, options: any = {}): Promise => { + // verify required parameter 'fileSchemaTestClass' is not null or undefined + assertParamExists('testBodyWithFileSchema', 'fileSchemaTestClass', fileSchemaTestClass) + const localVarPath = `/fake/body-with-file-schema`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(fileSchemaTestClass, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {string} query + * @param {User} user + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testBodyWithQueryParams: async (query: string, user: User, options: any = {}): Promise => { + // verify required parameter 'query' is not null or undefined + assertParamExists('testBodyWithQueryParams', 'query', query) + // verify required parameter 'user' is not null or undefined + assertParamExists('testBodyWithQueryParams', 'user', user) + const localVarPath = `/fake/body-with-query-params`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (query !== undefined) { + localVarQueryParameter['query'] = query; + } + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(user, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * To test \"client\" model + * @summary To test \"client\" model + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testClientModel: async (client: Client, options: any = {}): Promise => { + // verify required parameter 'client' is not null or undefined + assertParamExists('testClientModel', 'client', client) + const localVarPath = `/fake`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(client, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @summary Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param {number} number None + * @param {number} _double None + * @param {string} patternWithoutDelimiter None + * @param {string} _byte None + * @param {number} [integer] None + * @param {number} [int32] None + * @param {number} [int64] None + * @param {number} [_float] None + * @param {string} [string] None + * @param {any} [binary] None + * @param {string} [date] None + * @param {string} [dateTime] None + * @param {string} [password] None + * @param {string} [callback] None + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEndpointParameters: async (number: number, _double: number, patternWithoutDelimiter: string, _byte: string, integer?: number, int32?: number, int64?: number, _float?: number, string?: string, binary?: any, date?: string, dateTime?: string, password?: string, callback?: string, options: any = {}): Promise => { + // verify required parameter 'number' is not null or undefined + assertParamExists('testEndpointParameters', 'number', number) + // verify required parameter '_double' is not null or undefined + assertParamExists('testEndpointParameters', '_double', _double) + // verify required parameter 'patternWithoutDelimiter' is not null or undefined + assertParamExists('testEndpointParameters', 'patternWithoutDelimiter', patternWithoutDelimiter) + // verify required parameter '_byte' is not null or undefined + assertParamExists('testEndpointParameters', '_byte', _byte) + const localVarPath = `/fake`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new URLSearchParams(); + + // authentication http_basic_test required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration) + + + if (integer !== undefined) { + localVarFormParams.set('integer', integer as any); + } + + if (int32 !== undefined) { + localVarFormParams.set('int32', int32 as any); + } + + if (int64 !== undefined) { + localVarFormParams.set('int64', int64 as any); + } + + if (number !== undefined) { + localVarFormParams.set('number', number as any); + } + + if (_float !== undefined) { + localVarFormParams.set('float', _float as any); + } + + if (_double !== undefined) { + localVarFormParams.set('double', _double as any); + } + + if (string !== undefined) { + localVarFormParams.set('string', string as any); + } + + if (patternWithoutDelimiter !== undefined) { + localVarFormParams.set('pattern_without_delimiter', patternWithoutDelimiter as any); + } + + if (_byte !== undefined) { + localVarFormParams.set('byte', _byte as any); + } + + if (binary !== undefined) { + localVarFormParams.set('binary', binary as any); + } + + if (date !== undefined) { + localVarFormParams.set('date', date as any); + } + + if (dateTime !== undefined) { + localVarFormParams.set('dateTime', dateTime as any); + } + + if (password !== undefined) { + localVarFormParams.set('password', password as any); + } + + if (callback !== undefined) { + localVarFormParams.set('callback', callback as any); + } + + + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * To test enum parameters + * @summary To test enum parameters + * @param {Array<'>' | '$'>} [enumHeaderStringArray] Header parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumHeaderString] Header parameter enum test (string) + * @param {Array<'>' | '$'>} [enumQueryStringArray] Query parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumQueryString] Query parameter enum test (string) + * @param {1 | -2} [enumQueryInteger] Query parameter enum test (double) + * @param {1.1 | -1.2} [enumQueryDouble] Query parameter enum test (double) + * @param {Array} [enumFormStringArray] Form parameter enum test (string array) + * @param {string} [enumFormString] Form parameter enum test (string) + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEnumParameters: async (enumHeaderStringArray?: Array<'>' | '$'>, enumHeaderString?: '_abc' | '-efg' | '(xyz)', enumQueryStringArray?: Array<'>' | '$'>, enumQueryString?: '_abc' | '-efg' | '(xyz)', enumQueryInteger?: 1 | -2, enumQueryDouble?: 1.1 | -1.2, enumFormStringArray?: Array, enumFormString?: string, options: any = {}): Promise => { + const localVarPath = `/fake`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new URLSearchParams(); + + if (enumQueryStringArray) { + localVarQueryParameter['enum_query_string_array'] = enumQueryStringArray; + } + + if (enumQueryString !== undefined) { + localVarQueryParameter['enum_query_string'] = enumQueryString; + } + + if (enumQueryInteger !== undefined) { + localVarQueryParameter['enum_query_integer'] = enumQueryInteger; + } + + if (enumQueryDouble !== undefined) { + localVarQueryParameter['enum_query_double'] = enumQueryDouble; + } + + if (enumHeaderStringArray) { + let mapped = enumHeaderStringArray.map(value => ("Array<'>' | '$'>" !== "Array") ? JSON.stringify(value) : (value || "")); + localVarHeaderParameter['enum_header_string_array'] = mapped.join(COLLECTION_FORMATS["csv"]); + } + + if (enumHeaderString !== undefined && enumHeaderString !== null) { + localVarHeaderParameter['enum_header_string'] = String(enumHeaderString); + } + + if (enumFormStringArray) { + localVarFormParams.set(enumFormStringArray.join(COLLECTION_FORMATS.csv)); + } + + + if (enumFormString !== undefined) { + localVarFormParams.set('enum_form_string', enumFormString as any); + } + + + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Fake endpoint to test group parameters (optional) + * @summary Fake endpoint to test group parameters (optional) + * @param {number} requiredStringGroup Required String in group parameters + * @param {boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {number} requiredInt64Group Required Integer in group parameters + * @param {number} [stringGroup] String in group parameters + * @param {boolean} [booleanGroup] Boolean in group parameters + * @param {number} [int64Group] Integer in group parameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testGroupParameters: async (requiredStringGroup: number, requiredBooleanGroup: boolean, requiredInt64Group: number, stringGroup?: number, booleanGroup?: boolean, int64Group?: number, options: any = {}): Promise => { + // verify required parameter 'requiredStringGroup' is not null or undefined + assertParamExists('testGroupParameters', 'requiredStringGroup', requiredStringGroup) + // verify required parameter 'requiredBooleanGroup' is not null or undefined + assertParamExists('testGroupParameters', 'requiredBooleanGroup', requiredBooleanGroup) + // verify required parameter 'requiredInt64Group' is not null or undefined + assertParamExists('testGroupParameters', 'requiredInt64Group', requiredInt64Group) + const localVarPath = `/fake`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication bearer_test required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration) + + if (requiredStringGroup !== undefined) { + localVarQueryParameter['required_string_group'] = requiredStringGroup; + } + + if (requiredInt64Group !== undefined) { + localVarQueryParameter['required_int64_group'] = requiredInt64Group; + } + + if (stringGroup !== undefined) { + localVarQueryParameter['string_group'] = stringGroup; + } + + if (int64Group !== undefined) { + localVarQueryParameter['int64_group'] = int64Group; + } + + if (requiredBooleanGroup !== undefined && requiredBooleanGroup !== null) { + localVarHeaderParameter['required_boolean_group'] = String(JSON.stringify(requiredBooleanGroup)); + } + + if (booleanGroup !== undefined && booleanGroup !== null) { + localVarHeaderParameter['boolean_group'] = String(JSON.stringify(booleanGroup)); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary test inline additionalProperties + * @param {{ [key: string]: string; }} requestBody request body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testInlineAdditionalProperties: async (requestBody: { [key: string]: string; }, options: any = {}): Promise => { + // verify required parameter 'requestBody' is not null or undefined + assertParamExists('testInlineAdditionalProperties', 'requestBody', requestBody) + const localVarPath = `/fake/inline-additionalProperties`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary test json serialization of form data + * @param {string} param field1 + * @param {string} param2 field2 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testJsonFormData: async (param: string, param2: string, options: any = {}): Promise => { + // verify required parameter 'param' is not null or undefined + assertParamExists('testJsonFormData', 'param', param) + // verify required parameter 'param2' is not null or undefined + assertParamExists('testJsonFormData', 'param2', param2) + const localVarPath = `/fake/jsonFormData`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new URLSearchParams(); + + + if (param !== undefined) { + localVarFormParams.set('param', param as any); + } + + if (param2 !== undefined) { + localVarFormParams.set('param2', param2 as any); + } + + + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * To test the collection format in query parameters + * @param {Array} pipe + * @param {Array} ioutil + * @param {Array} http + * @param {Array} url + * @param {Array} context + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testQueryParameterCollectionFormat: async (pipe: Array, ioutil: Array, http: Array, url: Array, context: Array, options: any = {}): Promise => { + // verify required parameter 'pipe' is not null or undefined + assertParamExists('testQueryParameterCollectionFormat', 'pipe', pipe) + // verify required parameter 'ioutil' is not null or undefined + assertParamExists('testQueryParameterCollectionFormat', 'ioutil', ioutil) + // verify required parameter 'http' is not null or undefined + assertParamExists('testQueryParameterCollectionFormat', 'http', http) + // verify required parameter 'url' is not null or undefined + assertParamExists('testQueryParameterCollectionFormat', 'url', url) + // verify required parameter 'context' is not null or undefined + assertParamExists('testQueryParameterCollectionFormat', 'context', context) + const localVarPath = `/fake/test-query-paramters`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (pipe) { + localVarQueryParameter['pipe'] = pipe; + } + + if (ioutil) { + localVarQueryParameter['ioutil'] = ioutil.join(COLLECTION_FORMATS.csv); + } + + if (http) { + localVarQueryParameter['http'] = http.join(COLLECTION_FORMATS.ssv); + } + + if (url) { + localVarQueryParameter['url'] = url.join(COLLECTION_FORMATS.csv); + } + + if (context) { + localVarQueryParameter['context'] = context; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * To test unique items in header and query parameters + * @param {Set} queryUnique + * @param {Set} headerUnique + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testUniqueItemsHeaderAndQueryParameterCollectionFormat: async (queryUnique: Set, headerUnique: Set, options: any = {}): Promise => { + // verify required parameter 'queryUnique' is not null or undefined + assertParamExists('testUniqueItemsHeaderAndQueryParameterCollectionFormat', 'queryUnique', queryUnique) + // verify required parameter 'headerUnique' is not null or undefined + assertParamExists('testUniqueItemsHeaderAndQueryParameterCollectionFormat', 'headerUnique', headerUnique) + const localVarPath = `/fake/test-unique-paramters`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (queryUnique) { + localVarQueryParameter['queryUnique'] = Array.from(queryUnique); + } + + if (headerUnique) { + let mapped = Array.from(headerUnique).map(value => ("Set" !== "Set") ? JSON.stringify(value) : (value || "")); + localVarHeaderParameter['headerUnique'] = mapped.join(COLLECTION_FORMATS["csv"]); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * FakeApi - functional programming interface + * @export + */ +export const FakeApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = FakeApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Health check endpoint + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fakeHealthGet(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fakeHealthGet(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Test serialization of outer boolean types + * @param {boolean} [body] Input boolean as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fakeOuterBooleanSerialize(body?: boolean, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fakeOuterBooleanSerialize(body, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Test serialization of object with outer number type + * @param {OuterComposite} [outerComposite] Input composite as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fakeOuterCompositeSerialize(outerComposite?: OuterComposite, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fakeOuterCompositeSerialize(outerComposite, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Test serialization of outer number types + * @param {number} [body] Input number as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fakeOuterNumberSerialize(body?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fakeOuterNumberSerialize(body, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Test serialization of outer string types + * @param {string} [body] Input string as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async fakeOuterStringSerialize(body?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.fakeOuterStringSerialize(body, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * For this test, the body for this request much reference a schema named `File`. + * @param {FileSchemaTestClass} fileSchemaTestClass + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testBodyWithFileSchema(fileSchemaTestClass, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @param {string} query + * @param {User} user + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testBodyWithQueryParams(query: string, user: User, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testBodyWithQueryParams(query, user, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * To test \"client\" model + * @summary To test \"client\" model + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testClientModel(client: Client, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testClientModel(client, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @summary Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param {number} number None + * @param {number} _double None + * @param {string} patternWithoutDelimiter None + * @param {string} _byte None + * @param {number} [integer] None + * @param {number} [int32] None + * @param {number} [int64] None + * @param {number} [_float] None + * @param {string} [string] None + * @param {any} [binary] None + * @param {string} [date] None + * @param {string} [dateTime] None + * @param {string} [password] None + * @param {string} [callback] None + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testEndpointParameters(number: number, _double: number, patternWithoutDelimiter: string, _byte: string, integer?: number, int32?: number, int64?: number, _float?: number, string?: string, binary?: any, date?: string, dateTime?: string, password?: string, callback?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, callback, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * To test enum parameters + * @summary To test enum parameters + * @param {Array<'>' | '$'>} [enumHeaderStringArray] Header parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumHeaderString] Header parameter enum test (string) + * @param {Array<'>' | '$'>} [enumQueryStringArray] Query parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumQueryString] Query parameter enum test (string) + * @param {1 | -2} [enumQueryInteger] Query parameter enum test (double) + * @param {1.1 | -1.2} [enumQueryDouble] Query parameter enum test (double) + * @param {Array} [enumFormStringArray] Form parameter enum test (string array) + * @param {string} [enumFormString] Form parameter enum test (string) + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testEnumParameters(enumHeaderStringArray?: Array<'>' | '$'>, enumHeaderString?: '_abc' | '-efg' | '(xyz)', enumQueryStringArray?: Array<'>' | '$'>, enumQueryString?: '_abc' | '-efg' | '(xyz)', enumQueryInteger?: 1 | -2, enumQueryDouble?: 1.1 | -1.2, enumFormStringArray?: Array, enumFormString?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Fake endpoint to test group parameters (optional) + * @summary Fake endpoint to test group parameters (optional) + * @param {number} requiredStringGroup Required String in group parameters + * @param {boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {number} requiredInt64Group Required Integer in group parameters + * @param {number} [stringGroup] String in group parameters + * @param {boolean} [booleanGroup] Boolean in group parameters + * @param {number} [int64Group] Integer in group parameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testGroupParameters(requiredStringGroup: number, requiredBooleanGroup: boolean, requiredInt64Group: number, stringGroup?: number, booleanGroup?: boolean, int64Group?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary test inline additionalProperties + * @param {{ [key: string]: string; }} requestBody request body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testInlineAdditionalProperties(requestBody: { [key: string]: string; }, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testInlineAdditionalProperties(requestBody, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary test json serialization of form data + * @param {string} param field1 + * @param {string} param2 field2 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testJsonFormData(param: string, param2: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testJsonFormData(param, param2, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * To test the collection format in query parameters + * @param {Array} pipe + * @param {Array} ioutil + * @param {Array} http + * @param {Array} url + * @param {Array} context + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testQueryParameterCollectionFormat(pipe: Array, ioutil: Array, http: Array, url: Array, context: Array, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * To test unique items in header and query parameters + * @param {Set} queryUnique + * @param {Set} headerUnique + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique: Set, headerUnique: Set, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique, headerUnique, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * FakeApi - factory interface + * @export + */ +export const FakeApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = FakeApiFp(configuration) + return { + /** + * + * @summary Health check endpoint + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeHealthGet(options?: any): AxiosPromise { + return localVarFp.fakeHealthGet(options).then((request) => request(axios, basePath)); + }, + /** + * Test serialization of outer boolean types + * @param {boolean} [body] Input boolean as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterBooleanSerialize(body?: boolean, options?: any): AxiosPromise { + return localVarFp.fakeOuterBooleanSerialize(body, options).then((request) => request(axios, basePath)); + }, + /** + * Test serialization of object with outer number type + * @param {OuterComposite} [outerComposite] Input composite as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterCompositeSerialize(outerComposite?: OuterComposite, options?: any): AxiosPromise { + return localVarFp.fakeOuterCompositeSerialize(outerComposite, options).then((request) => request(axios, basePath)); + }, + /** + * Test serialization of outer number types + * @param {number} [body] Input number as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterNumberSerialize(body?: number, options?: any): AxiosPromise { + return localVarFp.fakeOuterNumberSerialize(body, options).then((request) => request(axios, basePath)); + }, + /** + * Test serialization of outer string types + * @param {string} [body] Input string as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + fakeOuterStringSerialize(body?: string, options?: any): AxiosPromise { + return localVarFp.fakeOuterStringSerialize(body, options).then((request) => request(axios, basePath)); + }, + /** + * For this test, the body for this request much reference a schema named `File`. + * @param {FileSchemaTestClass} fileSchemaTestClass + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, options?: any): AxiosPromise { + return localVarFp.testBodyWithFileSchema(fileSchemaTestClass, options).then((request) => request(axios, basePath)); + }, + /** + * + * @param {string} query + * @param {User} user + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testBodyWithQueryParams(query: string, user: User, options?: any): AxiosPromise { + return localVarFp.testBodyWithQueryParams(query, user, options).then((request) => request(axios, basePath)); + }, + /** + * To test \"client\" model + * @summary To test \"client\" model + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testClientModel(client: Client, options?: any): AxiosPromise { + return localVarFp.testClientModel(client, options).then((request) => request(axios, basePath)); + }, + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @summary Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param {number} number None + * @param {number} _double None + * @param {string} patternWithoutDelimiter None + * @param {string} _byte None + * @param {number} [integer] None + * @param {number} [int32] None + * @param {number} [int64] None + * @param {number} [_float] None + * @param {string} [string] None + * @param {any} [binary] None + * @param {string} [date] None + * @param {string} [dateTime] None + * @param {string} [password] None + * @param {string} [callback] None + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEndpointParameters(number: number, _double: number, patternWithoutDelimiter: string, _byte: string, integer?: number, int32?: number, int64?: number, _float?: number, string?: string, binary?: any, date?: string, dateTime?: string, password?: string, callback?: string, options?: any): AxiosPromise { + return localVarFp.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, callback, options).then((request) => request(axios, basePath)); + }, + /** + * To test enum parameters + * @summary To test enum parameters + * @param {Array<'>' | '$'>} [enumHeaderStringArray] Header parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumHeaderString] Header parameter enum test (string) + * @param {Array<'>' | '$'>} [enumQueryStringArray] Query parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumQueryString] Query parameter enum test (string) + * @param {1 | -2} [enumQueryInteger] Query parameter enum test (double) + * @param {1.1 | -1.2} [enumQueryDouble] Query parameter enum test (double) + * @param {Array} [enumFormStringArray] Form parameter enum test (string array) + * @param {string} [enumFormString] Form parameter enum test (string) + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testEnumParameters(enumHeaderStringArray?: Array<'>' | '$'>, enumHeaderString?: '_abc' | '-efg' | '(xyz)', enumQueryStringArray?: Array<'>' | '$'>, enumQueryString?: '_abc' | '-efg' | '(xyz)', enumQueryInteger?: 1 | -2, enumQueryDouble?: 1.1 | -1.2, enumFormStringArray?: Array, enumFormString?: string, options?: any): AxiosPromise { + return localVarFp.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, options).then((request) => request(axios, basePath)); + }, + /** + * Fake endpoint to test group parameters (optional) + * @summary Fake endpoint to test group parameters (optional) + * @param {number} requiredStringGroup Required String in group parameters + * @param {boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {number} requiredInt64Group Required Integer in group parameters + * @param {number} [stringGroup] String in group parameters + * @param {boolean} [booleanGroup] Boolean in group parameters + * @param {number} [int64Group] Integer in group parameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testGroupParameters(requiredStringGroup: number, requiredBooleanGroup: boolean, requiredInt64Group: number, stringGroup?: number, booleanGroup?: boolean, int64Group?: number, options?: any): AxiosPromise { + return localVarFp.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary test inline additionalProperties + * @param {{ [key: string]: string; }} requestBody request body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testInlineAdditionalProperties(requestBody: { [key: string]: string; }, options?: any): AxiosPromise { + return localVarFp.testInlineAdditionalProperties(requestBody, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary test json serialization of form data + * @param {string} param field1 + * @param {string} param2 field2 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testJsonFormData(param: string, param2: string, options?: any): AxiosPromise { + return localVarFp.testJsonFormData(param, param2, options).then((request) => request(axios, basePath)); + }, + /** + * To test the collection format in query parameters + * @param {Array} pipe + * @param {Array} ioutil + * @param {Array} http + * @param {Array} url + * @param {Array} context + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testQueryParameterCollectionFormat(pipe: Array, ioutil: Array, http: Array, url: Array, context: Array, options?: any): AxiosPromise { + return localVarFp.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, options).then((request) => request(axios, basePath)); + }, + /** + * To test unique items in header and query parameters + * @param {Set} queryUnique + * @param {Set} headerUnique + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique: Set, headerUnique: Set, options?: any): AxiosPromise> { + return localVarFp.testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique, headerUnique, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * FakeApi - object-oriented interface + * @export + * @class FakeApi + * @extends {BaseAPI} + */ +export class FakeApi extends BaseAPI { + /** + * + * @summary Health check endpoint + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public fakeHealthGet(options?: any) { + return FakeApiFp(this.configuration).fakeHealthGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Test serialization of outer boolean types + * @param {boolean} [body] Input boolean as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public fakeOuterBooleanSerialize(body?: boolean, options?: any) { + return FakeApiFp(this.configuration).fakeOuterBooleanSerialize(body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Test serialization of object with outer number type + * @param {OuterComposite} [outerComposite] Input composite as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public fakeOuterCompositeSerialize(outerComposite?: OuterComposite, options?: any) { + return FakeApiFp(this.configuration).fakeOuterCompositeSerialize(outerComposite, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Test serialization of outer number types + * @param {number} [body] Input number as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public fakeOuterNumberSerialize(body?: number, options?: any) { + return FakeApiFp(this.configuration).fakeOuterNumberSerialize(body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Test serialization of outer string types + * @param {string} [body] Input string as post body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public fakeOuterStringSerialize(body?: string, options?: any) { + return FakeApiFp(this.configuration).fakeOuterStringSerialize(body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * For this test, the body for this request much reference a schema named `File`. + * @param {FileSchemaTestClass} fileSchemaTestClass + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, options?: any) { + return FakeApiFp(this.configuration).testBodyWithFileSchema(fileSchemaTestClass, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @param {string} query + * @param {User} user + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testBodyWithQueryParams(query: string, user: User, options?: any) { + return FakeApiFp(this.configuration).testBodyWithQueryParams(query, user, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * To test \"client\" model + * @summary To test \"client\" model + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testClientModel(client: Client, options?: any) { + return FakeApiFp(this.configuration).testClientModel(client, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @summary Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param {number} number None + * @param {number} _double None + * @param {string} patternWithoutDelimiter None + * @param {string} _byte None + * @param {number} [integer] None + * @param {number} [int32] None + * @param {number} [int64] None + * @param {number} [_float] None + * @param {string} [string] None + * @param {any} [binary] None + * @param {string} [date] None + * @param {string} [dateTime] None + * @param {string} [password] None + * @param {string} [callback] None + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testEndpointParameters(number: number, _double: number, patternWithoutDelimiter: string, _byte: string, integer?: number, int32?: number, int64?: number, _float?: number, string?: string, binary?: any, date?: string, dateTime?: string, password?: string, callback?: string, options?: any) { + return FakeApiFp(this.configuration).testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, callback, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * To test enum parameters + * @summary To test enum parameters + * @param {Array<'>' | '$'>} [enumHeaderStringArray] Header parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumHeaderString] Header parameter enum test (string) + * @param {Array<'>' | '$'>} [enumQueryStringArray] Query parameter enum test (string array) + * @param {'_abc' | '-efg' | '(xyz)'} [enumQueryString] Query parameter enum test (string) + * @param {1 | -2} [enumQueryInteger] Query parameter enum test (double) + * @param {1.1 | -1.2} [enumQueryDouble] Query parameter enum test (double) + * @param {Array} [enumFormStringArray] Form parameter enum test (string array) + * @param {string} [enumFormString] Form parameter enum test (string) + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testEnumParameters(enumHeaderStringArray?: Array<'>' | '$'>, enumHeaderString?: '_abc' | '-efg' | '(xyz)', enumQueryStringArray?: Array<'>' | '$'>, enumQueryString?: '_abc' | '-efg' | '(xyz)', enumQueryInteger?: 1 | -2, enumQueryDouble?: 1.1 | -1.2, enumFormStringArray?: Array, enumFormString?: string, options?: any) { + return FakeApiFp(this.configuration).testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Fake endpoint to test group parameters (optional) + * @summary Fake endpoint to test group parameters (optional) + * @param {number} requiredStringGroup Required String in group parameters + * @param {boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {number} requiredInt64Group Required Integer in group parameters + * @param {number} [stringGroup] String in group parameters + * @param {boolean} [booleanGroup] Boolean in group parameters + * @param {number} [int64Group] Integer in group parameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testGroupParameters(requiredStringGroup: number, requiredBooleanGroup: boolean, requiredInt64Group: number, stringGroup?: number, booleanGroup?: boolean, int64Group?: number, options?: any) { + return FakeApiFp(this.configuration).testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary test inline additionalProperties + * @param {{ [key: string]: string; }} requestBody request body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testInlineAdditionalProperties(requestBody: { [key: string]: string; }, options?: any) { + return FakeApiFp(this.configuration).testInlineAdditionalProperties(requestBody, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary test json serialization of form data + * @param {string} param field1 + * @param {string} param2 field2 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testJsonFormData(param: string, param2: string, options?: any) { + return FakeApiFp(this.configuration).testJsonFormData(param, param2, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * To test the collection format in query parameters + * @param {Array} pipe + * @param {Array} ioutil + * @param {Array} http + * @param {Array} url + * @param {Array} context + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testQueryParameterCollectionFormat(pipe: Array, ioutil: Array, http: Array, url: Array, context: Array, options?: any) { + return FakeApiFp(this.configuration).testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * To test unique items in header and query parameters + * @param {Set} queryUnique + * @param {Set} headerUnique + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique: Set, headerUnique: Set, options?: any) { + return FakeApiFp(this.configuration).testUniqueItemsHeaderAndQueryParameterCollectionFormat(queryUnique, headerUnique, options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * FakeClassnameTags123Api - axios parameter creator + * @export + */ +export const FakeClassnameTags123ApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * To test class name in snake case + * @summary To test class name in snake case + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testClassname: async (client: Client, options: any = {}): Promise => { + // verify required parameter 'client' is not null or undefined + assertParamExists('testClassname', 'client', client) + const localVarPath = `/fake_classname_test`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api_key_query required + await setApiKeyToObject(localVarQueryParameter, "api_key_query", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(client, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * FakeClassnameTags123Api - functional programming interface + * @export + */ +export const FakeClassnameTags123ApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = FakeClassnameTags123ApiAxiosParamCreator(configuration) + return { + /** + * To test class name in snake case + * @summary To test class name in snake case + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async testClassname(client: Client, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.testClassname(client, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * FakeClassnameTags123Api - factory interface + * @export + */ +export const FakeClassnameTags123ApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = FakeClassnameTags123ApiFp(configuration) + return { + /** + * To test class name in snake case + * @summary To test class name in snake case + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + testClassname(client: Client, options?: any): AxiosPromise { + return localVarFp.testClassname(client, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * FakeClassnameTags123Api - object-oriented interface + * @export + * @class FakeClassnameTags123Api + * @extends {BaseAPI} + */ +export class FakeClassnameTags123Api extends BaseAPI { + /** + * To test class name in snake case + * @summary To test class name in snake case + * @param {Client} client client model + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeClassnameTags123Api + */ + public testClassname(client: Client, options?: any) { + return FakeClassnameTags123ApiFp(this.configuration).testClassname(client, options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * PetApi - axios parameter creator + * @export + */ +export const PetApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addPet: async (pet: Pet, options: any = {}): Promise => { + // verify required parameter 'pet' is not null or undefined + assertParamExists('addPet', 'pet', pet) + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication http_signature_test required + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deletePet: async (petId: number, apiKey?: string, options: any = {}): Promise => { + // verify required parameter 'petId' is not null or undefined + assertParamExists('deletePet', 'petId', petId) + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + if (apiKey !== undefined && apiKey !== null) { + localVarHeaderParameter['api_key'] = String(apiKey); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByStatus: async (status: Array<'available' | 'pending' | 'sold'>, options: any = {}): Promise => { + // verify required parameter 'status' is not null or undefined + assertParamExists('findPetsByStatus', 'status', status) + const localVarPath = `/pet/findByStatus`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication http_signature_test required + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + if (status) { + localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS.csv); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByTags: async (tags: Array, options: any = {}): Promise => { + // verify required parameter 'tags' is not null or undefined + assertParamExists('findPetsByTags', 'tags', tags) + const localVarPath = `/pet/findByTags`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication http_signature_test required + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + if (tags) { + localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS.csv); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById: async (petId: number, options: any = {}): Promise => { + // verify required parameter 'petId' is not null or undefined + assertParamExists('getPetById', 'petId', petId) + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api_key required + await setApiKeyToObject(localVarHeaderParameter, "api_key", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePet: async (pet: Pet, options: any = {}): Promise => { + // verify required parameter 'pet' is not null or undefined + assertParamExists('updatePet', 'pet', pet) + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication http_signature_test required + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePetWithForm: async (petId: number, name?: string, status?: string, options: any = {}): Promise => { + // verify required parameter 'petId' is not null or undefined + assertParamExists('updatePetWithForm', 'petId', petId) + const localVarPath = `/pet/{petId}` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new URLSearchParams(); + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + + if (name !== undefined) { + localVarFormParams.set('name', name as any); + } + + if (status !== undefined) { + localVarFormParams.set('status', status as any); + } + + + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams.toString(); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + uploadFile: async (petId: number, additionalMetadata?: string, file?: any, options: any = {}): Promise => { + // verify required parameter 'petId' is not null or undefined + assertParamExists('uploadFile', 'petId', petId) + const localVarPath = `/pet/{petId}/uploadImage` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary uploads an image (required) + * @param {number} petId ID of pet to update + * @param {any} requiredFile file to upload + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + uploadFileWithRequiredFile: async (petId: number, requiredFile: any, additionalMetadata?: string, options: any = {}): Promise => { + // verify required parameter 'petId' is not null or undefined + assertParamExists('uploadFileWithRequiredFile', 'petId', petId) + // verify required parameter 'requiredFile' is not null or undefined + assertParamExists('uploadFileWithRequiredFile', 'requiredFile', requiredFile) + const localVarPath = `/fake/{petId}/uploadImageWithRequiredFile` + .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + // authentication petstore_auth required + // oauth required + await setOAuthToObject(localVarHeaderParameter, "petstore_auth", ["write:pets", "read:pets"], configuration) + + + if (additionalMetadata !== undefined) { + localVarFormParams.append('additionalMetadata', additionalMetadata as any); + } + + if (requiredFile !== undefined) { + localVarFormParams.append('requiredFile', requiredFile as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * PetApi - functional programming interface + * @export + */ +export const PetApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = PetApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async addPet(pet: Pet, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.addPet(pet, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deletePet(petId: number, apiKey?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deletePet(petId, apiKey, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findPetsByStatus(status, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async findPetsByTags(tags: Array, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.findPetsByTags(tags, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getPetById(petId: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getPetById(petId, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updatePet(pet: Pet, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updatePet(pet, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updatePetWithForm(petId, name, status, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.uploadFile(petId, additionalMetadata, file, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary uploads an image (required) + * @param {number} petId ID of pet to update + * @param {any} requiredFile file to upload + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async uploadFileWithRequiredFile(petId: number, requiredFile: any, additionalMetadata?: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * PetApi - factory interface + * @export + */ +export const PetApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = PetApiFp(configuration) + return { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addPet(pet: Pet, options?: any): AxiosPromise { + return localVarFp.addPet(pet, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deletePet(petId: number, apiKey?: string, options?: any): AxiosPromise { + return localVarFp.deletePet(petId, apiKey, options).then((request) => request(axios, basePath)); + }, + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): AxiosPromise> { + return localVarFp.findPetsByStatus(status, options).then((request) => request(axios, basePath)); + }, + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + findPetsByTags(tags: Array, options?: any): AxiosPromise> { + return localVarFp.findPetsByTags(tags, options).then((request) => request(axios, basePath)); + }, + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById(petId: number, options?: any): AxiosPromise { + return localVarFp.getPetById(petId, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePet(pet: Pet, options?: any): AxiosPromise { + return localVarFp.updatePet(pet, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): AxiosPromise { + return localVarFp.updatePetWithForm(petId, name, status, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): AxiosPromise { + return localVarFp.uploadFile(petId, additionalMetadata, file, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary uploads an image (required) + * @param {number} petId ID of pet to update + * @param {any} requiredFile file to upload + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + uploadFileWithRequiredFile(petId: number, requiredFile: any, additionalMetadata?: string, options?: any): AxiosPromise { + return localVarFp.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * PetApi - object-oriented interface + * @export + * @class PetApi + * @extends {BaseAPI} + */ +export class PetApi extends BaseAPI { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public addPet(pet: Pet, options?: any) { + return PetApiFp(this.configuration).addPet(pet, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public deletePet(petId: number, apiKey?: string, options?: any) { + return PetApiFp(this.configuration).deletePet(petId, apiKey, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any) { + return PetApiFp(this.configuration).findPetsByStatus(status, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public findPetsByTags(tags: Array, options?: any) { + return PetApiFp(this.configuration).findPetsByTags(tags, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public getPetById(petId: number, options?: any) { + return PetApiFp(this.configuration).getPetById(petId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public updatePet(pet: Pet, options?: any) { + return PetApiFp(this.configuration).updatePet(pet, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public updatePetWithForm(petId: number, name?: string, status?: string, options?: any) { + return PetApiFp(this.configuration).updatePetWithForm(petId, name, status, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) { + return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary uploads an image (required) + * @param {number} petId ID of pet to update + * @param {any} requiredFile file to upload + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApi + */ + public uploadFileWithRequiredFile(petId: number, requiredFile: any, additionalMetadata?: string, options?: any) { + return PetApiFp(this.configuration).uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * StoreApi - axios parameter creator + * @export + */ +export const StoreApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOrder: async (orderId: string, options: any = {}): Promise => { + // verify required parameter 'orderId' is not null or undefined + assertParamExists('deleteOrder', 'orderId', orderId) + const localVarPath = `/store/order/{order_id}` + .replace(`{${"order_id"}}`, encodeURIComponent(String(orderId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory: async (options: any = {}): Promise => { + const localVarPath = `/store/inventory`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication api_key required + await setApiKeyToObject(localVarHeaderParameter, "api_key", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOrderById: async (orderId: number, options: any = {}): Promise => { + // verify required parameter 'orderId' is not null or undefined + assertParamExists('getOrderById', 'orderId', orderId) + const localVarPath = `/store/order/{order_id}` + .replace(`{${"order_id"}}`, encodeURIComponent(String(orderId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + placeOrder: async (order: Order, options: any = {}): Promise => { + // verify required parameter 'order' is not null or undefined + assertParamExists('placeOrder', 'order', order) + const localVarPath = `/store/order`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(order, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * StoreApi - functional programming interface + * @export + */ +export const StoreApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = StoreApiAxiosParamCreator(configuration) + return { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deleteOrder(orderId: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deleteOrder(orderId, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getInventory(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: number; }>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getInventory(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getOrderById(orderId: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getOrderById(orderId, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async placeOrder(order: Order, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.placeOrder(order, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * StoreApi - factory interface + * @export + */ +export const StoreApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = StoreApiFp(configuration) + return { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOrder(orderId: string, options?: any): AxiosPromise { + return localVarFp.deleteOrder(orderId, options).then((request) => request(axios, basePath)); + }, + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options?: any): AxiosPromise<{ [key: string]: number; }> { + return localVarFp.getInventory(options).then((request) => request(axios, basePath)); + }, + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOrderById(orderId: number, options?: any): AxiosPromise { + return localVarFp.getOrderById(orderId, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + placeOrder(order: Order, options?: any): AxiosPromise { + return localVarFp.placeOrder(order, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * StoreApi - object-oriented interface + * @export + * @class StoreApi + * @extends {BaseAPI} + */ +export class StoreApi extends BaseAPI { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public deleteOrder(orderId: string, options?: any) { + return StoreApiFp(this.configuration).deleteOrder(orderId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public getInventory(options?: any) { + return StoreApiFp(this.configuration).getInventory(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public getOrderById(orderId: number, options?: any) { + return StoreApiFp(this.configuration).getOrderById(orderId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApi + */ + public placeOrder(order: Order, options?: any) { + return StoreApiFp(this.configuration).placeOrder(order, options).then((request) => request(this.axios, this.basePath)); + } +} + + +/** + * UserApi - axios parameter creator + * @export + */ +export const UserApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUser: async (user: User, options: any = {}): Promise => { + // verify required parameter 'user' is not null or undefined + assertParamExists('createUser', 'user', user) + const localVarPath = `/user`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(user, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput: async (user: Array, options: any = {}): Promise => { + // verify required parameter 'user' is not null or undefined + assertParamExists('createUsersWithArrayInput', 'user', user) + const localVarPath = `/user/createWithArray`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(user, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput: async (user: Array, options: any = {}): Promise => { + // verify required parameter 'user' is not null or undefined + assertParamExists('createUsersWithListInput', 'user', user) + const localVarPath = `/user/createWithList`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(user, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUser: async (username: string, options: any = {}): Promise => { + // verify required parameter 'username' is not null or undefined + assertParamExists('deleteUser', 'username', username) + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserByName: async (username: string, options: any = {}): Promise => { + // verify required parameter 'username' is not null or undefined + assertParamExists('getUserByName', 'username', username) + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + loginUser: async (username: string, password: string, options: any = {}): Promise => { + // verify required parameter 'username' is not null or undefined + assertParamExists('loginUser', 'username', username) + // verify required parameter 'password' is not null or undefined + assertParamExists('loginUser', 'password', password) + const localVarPath = `/user/login`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (username !== undefined) { + localVarQueryParameter['username'] = username; + } + + if (password !== undefined) { + localVarQueryParameter['password'] = password; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser: async (options: any = {}): Promise => { + const localVarPath = `/user/logout`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUser: async (username: string, user: User, options: any = {}): Promise => { + // verify required parameter 'username' is not null or undefined + assertParamExists('updateUser', 'username', username) + // verify required parameter 'user' is not null or undefined + assertParamExists('updateUser', 'user', user) + const localVarPath = `/user/{username}` + .replace(`{${"username"}}`, encodeURIComponent(String(username))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(user, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * UserApi - functional programming interface + * @export + */ +export const UserApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = UserApiAxiosParamCreator(configuration) + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createUser(user: User, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createUser(user, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createUsersWithArrayInput(user: Array, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createUsersWithArrayInput(user, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createUsersWithListInput(user: Array, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createUsersWithListInput(user, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deleteUser(username: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deleteUser(username, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getUserByName(username: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getUserByName(username, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async loginUser(username: string, password: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.loginUser(username, password, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async logoutUser(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.logoutUser(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async updateUser(username: string, user: User, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.updateUser(username, user, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, + } +}; + +/** + * UserApi - factory interface + * @export + */ +export const UserApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = UserApiFp(configuration) + return { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUser(user: User, options?: any): AxiosPromise { + return localVarFp.createUser(user, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithArrayInput(user: Array, options?: any): AxiosPromise { + return localVarFp.createUsersWithArrayInput(user, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUsersWithListInput(user: Array, options?: any): AxiosPromise { + return localVarFp.createUsersWithListInput(user, options).then((request) => request(axios, basePath)); + }, + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUser(username: string, options?: any): AxiosPromise { + return localVarFp.deleteUser(username, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserByName(username: string, options?: any): AxiosPromise { + return localVarFp.getUserByName(username, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + loginUser(username: string, password: string, options?: any): AxiosPromise { + return localVarFp.loginUser(username, password, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + logoutUser(options?: any): AxiosPromise { + return localVarFp.logoutUser(options).then((request) => request(axios, basePath)); + }, + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUser(username: string, user: User, options?: any): AxiosPromise { + return localVarFp.updateUser(username, user, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * UserApi - object-oriented interface + * @export + * @class UserApi + * @extends {BaseAPI} + */ +export class UserApi extends BaseAPI { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUser(user: User, options?: any) { + return UserApiFp(this.configuration).createUser(user, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithArrayInput(user: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithArrayInput(user, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public createUsersWithListInput(user: Array, options?: any) { + return UserApiFp(this.configuration).createUsersWithListInput(user, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public deleteUser(username: string, options?: any) { + return UserApiFp(this.configuration).deleteUser(username, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public getUserByName(username: string, options?: any) { + return UserApiFp(this.configuration).getUserByName(username, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public loginUser(username: string, password: string, options?: any) { + return UserApiFp(this.configuration).loginUser(username, password, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public logoutUser(options?: any) { + return UserApiFp(this.configuration).logoutUser(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public updateUser(username: string, user: User, options?: any) { + return UserApiFp(this.configuration).updateUser(username, user, options).then((request) => request(this.axios, this.basePath)); + } +} + + diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/base.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/base.ts new file mode 100644 index 00000000000..ffc1b092d6e --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/base.ts @@ -0,0 +1,71 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { Configuration } from "./configuration"; +// Some imports not used depending on template conditions +// @ts-ignore +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "http://petstore.swagger.io:80/v2".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts new file mode 100644 index 00000000000..35e91dfeee8 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts @@ -0,0 +1,138 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { Configuration } from "./configuration"; +import { RequiredError, RequestArgs } from "./base"; +import { AxiosInstance } from 'axios'; + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + for (const object of objects) { + for (const key in object) { + if (Array.isArray(object[key])) { + searchParams.delete(key); + for (const item of object[key]) { + searchParams.append(key, item); + } + } else { + searchParams.set(key, object[key]); + } + } + } + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/configuration.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/configuration.ts new file mode 100644 index 00000000000..9d6922b1165 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/configuration.ts @@ -0,0 +1,101 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/git_push.sh b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/git_push.sh new file mode 100644 index 00000000000..ced3be2b0c7 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/git_push.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/index.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/index.ts new file mode 100644 index 00000000000..7ffd3df3280 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/index.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export * from "./api"; +export * from "./configuration"; + diff --git a/samples/openapi3/client/petstore/go/go-petstore/README.md b/samples/openapi3/client/petstore/go/go-petstore/README.md index d09a686f837..e74890dab41 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/README.md +++ b/samples/openapi3/client/petstore/go/go-petstore/README.md @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **Get** /fake/jsonFormData | test json serialization of form data *FakeApi* | [**TestQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **Put** /fake/test-query-paramters | +*FakeApi* | [**TestUniqueItemsHeaderAndQueryParameterCollectionFormat**](docs/FakeApi.md#testuniqueitemsheaderandqueryparametercollectionformat) | **Put** /fake/test-unique-paramters | *FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **Patch** /fake_classname_test | To test class name in snake case *PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **Post** /pet | Add a new pet to the store *PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **Delete** /pet/{petId} | Deletes a pet diff --git a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml index c55a3aec4ac..e0fba9d45fe 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml +++ b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml @@ -1120,6 +1120,43 @@ paths: description: Success tags: - fake + /fake/test-unique-paramters: + put: + description: To test unique items in header and query parameters + operationId: testUniqueItemsHeaderAndQueryParameterCollectionFormat + parameters: + - explode: true + in: query + name: queryUnique + required: true + schema: + items: + type: string + type: array + uniqueItems: true + style: form + - explode: false + in: header + name: headerUnique + required: true + schema: + items: + type: string + type: array + uniqueItems: true + style: simple + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: Success + tags: + - fake /fake/{petId}/uploadImageWithRequiredFile: post: operationId: uploadFileWithRequiredFile diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go index c7d9644d638..0780536bcbb 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go @@ -215,6 +215,20 @@ type FakeApi interface { * TestQueryParameterCollectionFormatExecute executes the request */ TestQueryParameterCollectionFormatExecute(r ApiTestQueryParameterCollectionFormatRequest) (*_nethttp.Response, error) + + /* + * TestUniqueItemsHeaderAndQueryParameterCollectionFormat Method for TestUniqueItemsHeaderAndQueryParameterCollectionFormat + * To test unique items in header and query parameters + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest + */ + TestUniqueItemsHeaderAndQueryParameterCollectionFormat(ctx _context.Context) ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest + + /* + * TestUniqueItemsHeaderAndQueryParameterCollectionFormatExecute executes the request + * @return []Pet + */ + TestUniqueItemsHeaderAndQueryParameterCollectionFormatExecute(r ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest) ([]Pet, *_nethttp.Response, error) } // FakeApiService FakeApi service @@ -1978,3 +1992,133 @@ func (a *FakeApiService) TestQueryParameterCollectionFormatExecute(r ApiTestQuer return localVarHTTPResponse, nil } + +type ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest struct { + ctx _context.Context + ApiService FakeApi + queryUnique *[]string + headerUnique *[]string +} + +func (r ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest) QueryUnique(queryUnique []string) ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest { + r.queryUnique = &queryUnique + return r +} +func (r ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest) HeaderUnique(headerUnique []string) ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest { + r.headerUnique = &headerUnique + return r +} + +func (r ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest) Execute() ([]Pet, *_nethttp.Response, error) { + return r.ApiService.TestUniqueItemsHeaderAndQueryParameterCollectionFormatExecute(r) +} + +/* + * TestUniqueItemsHeaderAndQueryParameterCollectionFormat Method for TestUniqueItemsHeaderAndQueryParameterCollectionFormat + * To test unique items in header and query parameters + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest + */ +func (a *FakeApiService) TestUniqueItemsHeaderAndQueryParameterCollectionFormat(ctx _context.Context) ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest { + return ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return []Pet + */ +func (a *FakeApiService) TestUniqueItemsHeaderAndQueryParameterCollectionFormatExecute(r ApiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest) ([]Pet, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Pet + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FakeApiService.TestUniqueItemsHeaderAndQueryParameterCollectionFormat") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/fake/test-unique-paramters" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.queryUnique == nil { + return localVarReturnValue, nil, reportError("queryUnique is required and must be specified") + } + if r.headerUnique == nil { + return localVarReturnValue, nil, reportError("headerUnique is required and must be specified") + } + + { + t := *r.queryUnique + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + localVarQueryParams.Add("queryUnique", parameterToString(s.Index(i), "multi")) + } + } else { + localVarQueryParams.Add("queryUnique", parameterToString(t, "multi")) + } + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + localVarHeaderParams["headerUnique"] = parameterToString(*r.headerUnique, "csv") + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md index 9021892276c..8ced9ff7c2a 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeApi.md @@ -18,6 +18,7 @@ Method | HTTP request | Description [**TestInlineAdditionalProperties**](FakeApi.md#TestInlineAdditionalProperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties [**TestJsonFormData**](FakeApi.md#TestJsonFormData) | **Get** /fake/jsonFormData | test json serialization of form data [**TestQueryParameterCollectionFormat**](FakeApi.md#TestQueryParameterCollectionFormat) | **Put** /fake/test-query-paramters | +[**TestUniqueItemsHeaderAndQueryParameterCollectionFormat**](FakeApi.md#TestUniqueItemsHeaderAndQueryParameterCollectionFormat) | **Put** /fake/test-unique-paramters | @@ -978,3 +979,71 @@ No authorization required [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## TestUniqueItemsHeaderAndQueryParameterCollectionFormat + +> []Pet TestUniqueItemsHeaderAndQueryParameterCollectionFormat(ctx).QueryUnique(queryUnique).HeaderUnique(headerUnique).Execute() + + + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + queryUnique := []string{"Inner_example"} // []string | + headerUnique := []string{"Inner_example"} // []string | + + configuration := openapiclient.NewConfiguration() + api_client := openapiclient.NewAPIClient(configuration) + resp, r, err := api_client.FakeApi.TestUniqueItemsHeaderAndQueryParameterCollectionFormat(context.Background()).QueryUnique(queryUnique).HeaderUnique(headerUnique).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FakeApi.TestUniqueItemsHeaderAndQueryParameterCollectionFormat``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `TestUniqueItemsHeaderAndQueryParameterCollectionFormat`: []Pet + fmt.Fprintf(os.Stdout, "Response from `FakeApi.TestUniqueItemsHeaderAndQueryParameterCollectionFormat`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiTestUniqueItemsHeaderAndQueryParameterCollectionFormatRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **queryUnique** | **[]string** | | + **headerUnique** | **[]string** | | + +### Return type + +[**[]Pet**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + From 71f67c3d40f00d3e73c576f8984ca09b5f1e307b Mon Sep 17 00:00:00 2001 From: Justin Black Date: Thu, 1 Apr 2021 11:31:21 -0700 Subject: [PATCH 12/99] Samples regenerated (#9154) --- .../docs/FakeApi.md | 4 ++-- .../petstore_client_lib_fake/.openapi-generator/VERSION | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md index a107342b75c..bfd6467215b 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/docs/FakeApi.md @@ -842,13 +842,13 @@ with petstore_api.ApiClient(configuration) as api_client: api_instance = fake_api.FakeApi(api_client) number = 32.1 # float | None double = 67.8 # float | None - pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + pattern_without_delimiter = "Aj" # str | None byte = 'YQ==' # str | None integer = 10 # int | None (optional) int32 = 20 # int | None (optional) int64 = 1 # int | None (optional) float = 3.14 # float | None (optional) - string = "a" # str | None (optional) + string = "A" # str | None (optional) binary = open('/path/to/file', 'rb') # file_type | None (optional) date = dateutil_parser('1970-01-01').date() # date | None (optional) date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional) diff --git a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/VERSION b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/VERSION index d509cc92aa8..6555596f931 100644 --- a/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake/.openapi-generator/VERSION @@ -1 +1 @@ -5.1.1-SNAPSHOT \ No newline at end of file +5.2.0-SNAPSHOT \ No newline at end of file From fc58adee312b4b2684b9bd4dbfb57ca1c7eaa3a5 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Thu, 1 Apr 2021 13:34:19 -0700 Subject: [PATCH 13/99] Fixes serialization of array items in model_to_dict [python] (#9153) * Adds tests of endpoint with inline and refed model * Regen samples * Samples regenerated --- .../resources/python/model_utils.mustache | 20 +- ...odels-for-testing-with-http-signature.yaml | 75 ++++++ .../python/petstore_api/model_utils.py | 20 +- .../python/x_auth_id_alias/model_utils.py | 20 +- .../python/dynamic_servers/model_utils.py | 20 +- .../petstore/python/.openapi-generator/FILES | 6 + .../openapi3/client/petstore/python/README.md | 5 + .../client/petstore/python/docs/FakeApi.md | 144 +++++++++++ ...ineAdditionalPropertiesPayloadArrayData.md | 11 + .../InlineAdditionalPropertiesRefPayload.md | 12 + .../petstore/python/docs/InlineObject6.md | 12 + .../python/petstore_api/api/fake_api.py | 224 ++++++++++++++++++ ...dditional_properties_payload_array_data.py | 166 +++++++++++++ ...nline_additional_properties_ref_payload.py | 171 +++++++++++++ .../petstore_api/model/inline_object6.py | 171 +++++++++++++ .../python/petstore_api/model_utils.py | 20 +- .../python/petstore_api/models/__init__.py | 3 + .../petstore/python/test/test_fake_api.py | 49 +++- ...dditional_properties_payload_array_data.py | 35 +++ ...nline_additional_properties_ref_payload.py | 37 +++ .../python/test/test_inline_object6.py | 37 +++ .../python/tests_manual/test_fake_api.py | 69 ++++++ 22 files changed, 1290 insertions(+), 37 deletions(-) create mode 100644 samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md create mode 100644 samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md create mode 100644 samples/openapi3/client/petstore/python/docs/InlineObject6.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py create mode 100644 samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py create mode 100644 samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py create mode 100644 samples/openapi3/client/petstore/python/test/test_inline_object6.py diff --git a/modules/openapi-generator/src/main/resources/python/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/model_utils.mustache index 07b77a99d18..396948e0a35 100644 --- a/modules/openapi-generator/src/main/resources/python/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_utils.mustache @@ -1211,13 +1211,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index bd29a22a5f9..dc3743a492a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1286,6 +1286,66 @@ paths: application/json: schema: $ref: '#/components/schemas/HealthCheckResult' + /fake/getInlineAdditionalPropertiesRefPayload: + get: + tags: + - fake + operationId: getInlineAdditionalPropertiesRefPayload + responses: + 200: + description: InlineAdditionalPropertiesRefPayload + content: + application/json: + schema: + $ref: '#/components/schemas/InlineAdditionalPropertiesRefPayload' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InlineAdditionalPropertiesRefPayload' + /fake/getInlineAdditionalPropertiesPayload: + get: + tags: + - fake + operationId: getInlineAdditionalPropertiesPayload + responses: + 200: + description: InlineAdditionalPropertiesPayload + content: + application/json: + schema: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true + requestBody: + content: + application/json: + schema: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true servers: - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server @@ -2318,3 +2378,18 @@ components: SomeObject: allOf: - $ref: '#/components/schemas/ObjectInterface' + InlineAdditionalPropertiesRefPayload: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true \ No newline at end of file diff --git a/samples/client/petstore/python/petstore_api/model_utils.py b/samples/client/petstore/python/petstore_api/model_utils.py index ae554710670..11a6cbf2d1b 100644 --- a/samples/client/petstore/python/petstore_api/model_utils.py +++ b/samples/client/petstore/python/petstore_api/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py index 3276615fd49..84c8c74a7f6 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py index 7edd9487c37..6bb0bd10234 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index aa906bc845d..a6f26c9c81f 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -39,6 +39,7 @@ docs/EnumTest.md docs/EquilateralTriangle.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md docs/File.md docs/FileSchemaTestClass.md docs/Foo.md @@ -49,6 +50,8 @@ docs/GmFruit.md docs/GrandparentAnimal.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/InlineAdditionalPropertiesRefPayload.md +docs/InlineObject6.md docs/InlineResponseDefault.md docs/IntegerEnum.md docs/IntegerEnumOneValue.md @@ -142,6 +145,7 @@ petstore_api/model/enum_arrays.py petstore_api/model/enum_class.py petstore_api/model/enum_test.py petstore_api/model/equilateral_triangle.py +petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py petstore_api/model/file.py petstore_api/model/file_schema_test_class.py petstore_api/model/foo.py @@ -152,6 +156,8 @@ petstore_api/model/gm_fruit.py petstore_api/model/grandparent_animal.py petstore_api/model/has_only_read_only.py petstore_api/model/health_check_result.py +petstore_api/model/inline_additional_properties_ref_payload.py +petstore_api/model/inline_object6.py petstore_api/model/inline_response_default.py petstore_api/model/integer_enum.py petstore_api/model/integer_enum_one_value.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 61aebac0aa1..49e1220659f 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -91,6 +91,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**download_attachment**](docs/FakeApi.md#download_attachment) | **GET** /{fileName} | downloads a file using Content-Disposition *FakeApi* | [**enum_test**](docs/FakeApi.md#enum_test) | **POST** /fake/refs/enum-test | Object contains enum properties and array properties containing enums *FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +*FakeApi* | [**get_inline_additional_properties_payload**](docs/FakeApi.md#get_inline_additional_properties_payload) | **GET** /fake/getInlineAdditionalPropertiesPayload | +*FakeApi* | [**get_inline_additional_properties_ref_payload**](docs/FakeApi.md#get_inline_additional_properties_ref_payload) | **GET** /fake/getInlineAdditionalPropertiesRefPayload | *FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal | *FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number | *FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | @@ -165,6 +167,7 @@ Class | Method | HTTP request | Description - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) - [EquilateralTriangle](docs/EquilateralTriangle.md) + - [FakeGetInlineAdditionalPropertiesPayloadArrayData](docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [Foo](docs/Foo.md) @@ -175,6 +178,8 @@ Class | Method | HTTP request | Description - [GrandparentAnimal](docs/GrandparentAnimal.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [HealthCheckResult](docs/HealthCheckResult.md) + - [InlineAdditionalPropertiesRefPayload](docs/InlineAdditionalPropertiesRefPayload.md) + - [InlineObject6](docs/InlineObject6.md) - [InlineResponseDefault](docs/InlineResponseDefault.md) - [IntegerEnum](docs/IntegerEnum.md) - [IntegerEnumOneValue](docs/IntegerEnumOneValue.md) diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md index 3bb042e8845..acc41cb4899 100644 --- a/samples/openapi3/client/petstore/python/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md @@ -12,6 +12,8 @@ Method | HTTP request | Description [**download_attachment**](FakeApi.md#download_attachment) | **GET** /{fileName} | downloads a file using Content-Disposition [**enum_test**](FakeApi.md#enum_test) | **POST** /fake/refs/enum-test | Object contains enum properties and array properties containing enums [**fake_health_get**](FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +[**get_inline_additional_properties_payload**](FakeApi.md#get_inline_additional_properties_payload) | **GET** /fake/getInlineAdditionalPropertiesPayload | +[**get_inline_additional_properties_ref_payload**](FakeApi.md#get_inline_additional_properties_ref_payload) | **GET** /fake/getInlineAdditionalPropertiesRefPayload | [**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal | [**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number | [**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | @@ -562,6 +564,148 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **get_inline_additional_properties_payload** +> InlineObject6 get_inline_additional_properties_payload() + + + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.inline_object6 import InlineObject6 +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + inline_object6 = InlineObject6( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData( + labels=[ + "labels_example", + ], + ), + ], + ) # InlineObject6 | (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.get_inline_additional_properties_payload(inline_object6=inline_object6) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->get_inline_additional_properties_payload: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **inline_object6** | [**InlineObject6**](InlineObject6.md)| | [optional] + +### Return type + +[**InlineObject6**](InlineObject6.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | InlineAdditionalPropertiesPayload | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inline_additional_properties_ref_payload** +> InlineAdditionalPropertiesRefPayload get_inline_additional_properties_ref_payload() + + + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + inline_additional_properties_ref_payload = InlineAdditionalPropertiesRefPayload( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData( + labels=[ + "labels_example", + ], + ), + ], + ) # InlineAdditionalPropertiesRefPayload | (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.get_inline_additional_properties_ref_payload(inline_additional_properties_ref_payload=inline_additional_properties_ref_payload) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->get_inline_additional_properties_ref_payload: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **inline_additional_properties_ref_payload** | [**InlineAdditionalPropertiesRefPayload**](InlineAdditionalPropertiesRefPayload.md)| | [optional] + +### Return type + +[**InlineAdditionalPropertiesRefPayload**](InlineAdditionalPropertiesRefPayload.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | InlineAdditionalPropertiesRefPayload | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **mammal** > Mammal mammal(mammal) diff --git a/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md b/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md new file mode 100644 index 00000000000..0ba4e3b8e5a --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md @@ -0,0 +1,11 @@ +# FakeGetInlineAdditionalPropertiesPayloadArrayData + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**labels** | **[str, none_type]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md b/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md new file mode 100644 index 00000000000..130320d1daa --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md @@ -0,0 +1,12 @@ +# InlineAdditionalPropertiesRefPayload + +this payload is used for verification that some model_to_dict issues are fixed + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_data** | [**[FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type**](FakeGetInlineAdditionalPropertiesPayloadArrayData.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject6.md b/samples/openapi3/client/petstore/python/docs/InlineObject6.md new file mode 100644 index 00000000000..6e4975b3542 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/InlineObject6.md @@ -0,0 +1,12 @@ +# InlineObject6 + +this payload is used for verification that some model_to_dict issues are fixed + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_data** | [**[FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type**](FakeGetInlineAdditionalPropertiesPayloadArrayData.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 6baed5ea63d..5f98e228c3b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -30,6 +30,8 @@ from petstore_api.model.composed_one_of_number_with_validations import ComposedO from petstore_api.model.enum_test import EnumTest from petstore_api.model.file_schema_test_class import FileSchemaTestClass from petstore_api.model.health_check_result import HealthCheckResult +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +from petstore_api.model.inline_object6 import InlineObject6 from petstore_api.model.mammal import Mammal from petstore_api.model.number_with_validations import NumberWithValidations from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps @@ -943,6 +945,228 @@ class FakeApi(object): callable=__fake_health_get ) + def __get_inline_additional_properties_payload( + self, + **kwargs + ): + """get_inline_additional_properties_payload # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inline_additional_properties_payload(async_req=True) + >>> result = thread.get() + + + Keyword Args: + inline_object6 (InlineObject6): [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + InlineObject6 + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.get_inline_additional_properties_payload = _Endpoint( + settings={ + 'response_type': (InlineObject6,), + 'auth': [], + 'endpoint_path': '/fake/getInlineAdditionalPropertiesPayload', + 'operation_id': 'get_inline_additional_properties_payload', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'inline_object6', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'inline_object6': + (InlineObject6,), + }, + 'attribute_map': { + }, + 'location_map': { + 'inline_object6': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__get_inline_additional_properties_payload + ) + + def __get_inline_additional_properties_ref_payload( + self, + **kwargs + ): + """get_inline_additional_properties_ref_payload # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inline_additional_properties_ref_payload(async_req=True) + >>> result = thread.get() + + + Keyword Args: + inline_additional_properties_ref_payload (InlineAdditionalPropertiesRefPayload): [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + InlineAdditionalPropertiesRefPayload + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + return self.call_with_http_info(**kwargs) + + self.get_inline_additional_properties_ref_payload = _Endpoint( + settings={ + 'response_type': (InlineAdditionalPropertiesRefPayload,), + 'auth': [], + 'endpoint_path': '/fake/getInlineAdditionalPropertiesRefPayload', + 'operation_id': 'get_inline_additional_properties_ref_payload', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'inline_additional_properties_ref_payload', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'inline_additional_properties_ref_payload': + (InlineAdditionalPropertiesRefPayload,), + }, + 'attribute_map': { + }, + 'location_map': { + 'inline_additional_properties_ref_payload': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__get_inline_additional_properties_ref_payload + ) + def __mammal( self, mammal, diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py b/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py new file mode 100644 index 00000000000..bbbc449b429 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py @@ -0,0 +1,166 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class FakeGetInlineAdditionalPropertiesPayloadArrayData(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'labels': ([str, none_type],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'labels': 'labels', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """FakeGetInlineAdditionalPropertiesPayloadArrayData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + labels ([str, none_type]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py b/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py new file mode 100644 index 00000000000..4d8e8aecff3 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py @@ -0,0 +1,171 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class InlineAdditionalPropertiesRefPayload(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'array_data': ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_data': 'arrayData', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """InlineAdditionalPropertiesRefPayload - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_data ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py b/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py new file mode 100644 index 00000000000..d60fec5fa68 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py @@ -0,0 +1,171 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class InlineObject6(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'array_data': ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_data': 'arrayData', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """InlineObject6 - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_data ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py index ae554710670..11a6cbf2d1b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 4941dc7de6e..1d9f8235ac7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -42,6 +42,7 @@ from petstore_api.model.enum_arrays import EnumArrays from petstore_api.model.enum_class import EnumClass from petstore_api.model.enum_test import EnumTest from petstore_api.model.equilateral_triangle import EquilateralTriangle +from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData from petstore_api.model.file import File from petstore_api.model.file_schema_test_class import FileSchemaTestClass from petstore_api.model.foo import Foo @@ -52,6 +53,8 @@ from petstore_api.model.gm_fruit import GmFruit from petstore_api.model.grandparent_animal import GrandparentAnimal from petstore_api.model.has_only_read_only import HasOnlyReadOnly from petstore_api.model.health_check_result import HealthCheckResult +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +from petstore_api.model.inline_object6 import InlineObject6 from petstore_api.model.inline_response_default import InlineResponseDefault from petstore_api.model.integer_enum import IntegerEnum from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue diff --git a/samples/openapi3/client/petstore/python/test/test_fake_api.py b/samples/openapi3/client/petstore/python/test/test_fake_api.py index 48230221f42..8782dcd4c23 100644 --- a/samples/openapi3/client/petstore/python/test/test_fake_api.py +++ b/samples/openapi3/client/petstore/python/test/test_fake_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ OpenAPI Petstore @@ -57,6 +55,20 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_download_attachment(self): + """Test case for download_attachment + + downloads a file using Content-Disposition # noqa: E501 + """ + pass + + def test_enum_test(self): + """Test case for enum_test + + Object contains enum properties and array properties containing enums # noqa: E501 + """ + pass + def test_fake_health_get(self): """Test case for fake_health_get @@ -64,6 +76,18 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_get_inline_additionl_properties_ref_payload(self): + """Test case for get_inline_additionl_properties_ref_payload + + """ + pass + + def test_mammal(self): + """Test case for mammal + + """ + pass + def test_number_with_validations(self): """Test case for number_with_validations @@ -148,6 +172,27 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_upload_download_file(self): + """Test case for upload_download_file + + uploads a file and downloads a file using application/octet-stream # noqa: E501 + """ + pass + + def test_upload_file(self): + """Test case for upload_file + + uploads a file using multipart/form-data # noqa: E501 + """ + pass + + def test_upload_files(self): + """Test case for upload_files + + uploads files using multipart/form-data # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py b/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py new file mode 100644 index 00000000000..2e95eb37dff --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py @@ -0,0 +1,35 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class TestFakeGetInlineAdditionalPropertiesPayloadArrayData(unittest.TestCase): + """FakeGetInlineAdditionalPropertiesPayloadArrayData unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFakeGetInlineAdditionalPropertiesPayloadArrayData(self): + """Test FakeGetInlineAdditionalPropertiesPayloadArrayData""" + # FIXME: construct object with mandatory attributes with example values + # model = FakeGetInlineAdditionalPropertiesPayloadArrayData() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py b/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py new file mode 100644 index 00000000000..709ee27adc8 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py @@ -0,0 +1,37 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData +globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload + + +class TestInlineAdditionalPropertiesRefPayload(unittest.TestCase): + """InlineAdditionalPropertiesRefPayload unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testInlineAdditionalPropertiesRefPayload(self): + """Test InlineAdditionalPropertiesRefPayload""" + # FIXME: construct object with mandatory attributes with example values + # model = InlineAdditionalPropertiesRefPayload() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_inline_object6.py b/samples/openapi3/client/petstore/python/test/test_inline_object6.py new file mode 100644 index 00000000000..463123d8e55 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_inline_object6.py @@ -0,0 +1,37 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData +globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData +from petstore_api.model.inline_object6 import InlineObject6 + + +class TestInlineObject6(unittest.TestCase): + """InlineObject6 unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testInlineObject6(self): + """Test InlineObject6""" + # FIXME: construct object with mandatory attributes with example values + # model = InlineObject6() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py index 12fb6163684..8c0886e373b 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py @@ -604,6 +604,75 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_get_inline_additional_properties_ref_payload(self): + """Test case for getInlineAdditionlPropertiesRefPayload + """ + from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + endpoint = self.api.get_inline_additional_properties_ref_payload + assert endpoint.openapi_types['inline_additional_properties_ref_payload'] == (InlineAdditionalPropertiesRefPayload,) + assert endpoint.settings['response_type'] == (InlineAdditionalPropertiesRefPayload,) + + # serialization + deserialization works + from petstore_api.rest import RESTClientObject, RESTResponse + with patch.object(RESTClientObject, 'request') as mock_method: + expected_json_body = { + 'array_data': [ + { + 'labels': [ + None, + 'foo' + ] + } + ] + } + inline_additional_properties_ref_payload = InlineAdditionalPropertiesRefPayload( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData(labels=[None, 'foo']) + ] + ) + mock_method.return_value = self.mock_response(expected_json_body) + + response = endpoint(inline_additional_properties_ref_payload=inline_additional_properties_ref_payload) + self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', body=expected_json_body) + + assert isinstance(response, InlineAdditionalPropertiesRefPayload) + assert response.to_dict() == expected_json_body + + def test_get_inline_additional_properties_payload(self): + """Test case for getInlineAdditionlPropertiesPayload + """ + from petstore_api.model.inline_object6 import InlineObject6 + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + endpoint = self.api.get_inline_additional_properties_payload + assert endpoint.openapi_types['inline_object6'] == (InlineObject6,) + assert endpoint.settings['response_type'] == (InlineObject6,) + + # serialization + deserialization works + from petstore_api.rest import RESTClientObject, RESTResponse + with patch.object(RESTClientObject, 'request') as mock_method: + expected_json_body = { + 'array_data': [ + { + 'labels': [ + None, + 'foo' + ] + } + ] + } + inline_object6 = InlineObject6( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData(labels=[None, 'foo']) + ] + ) + mock_method.return_value = self.mock_response(expected_json_body) + + response = endpoint(inline_object6=inline_object6) + self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', body=expected_json_body) + + assert isinstance(response, InlineObject6) + assert response.to_dict() == expected_json_body if __name__ == '__main__': unittest.main() From 4db6f46a00a0f4d6ac2b082b4ca8dd81e7f731eb Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 3 Apr 2021 11:18:05 +0800 Subject: [PATCH 14/99] Add links to blog posts about openapi-generator (#9164) * Add links to blog posts about openapi-generator * add more articles * add more article --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5b36ced7376..84a876cf0b8 100644 --- a/README.md +++ b/README.md @@ -814,6 +814,12 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - 2021-01-18 - [「アプリ開発あるある」を疑うことから始まった、API Clientコードの自動生成【デブスト2020】](https://codezine.jp/article/detail/13406?p=2) by [CodeZine編集部](https://codezine.jp/author/1) - 2021-02-05 - [REST-API-Roundtrip with SpringDoc and OpenAPI Generator](https://blog.viadee.de/en/rest-api-roundtrip) by [Benjamin Klatt](https://twitter.com/benklatt) at [viadee](https://www.viadee.de/en/) - 2021-02-17 - [REST-API-Roundtrip with SpringDoc and OpenAPI Generator](https://medium.com/nerd-for-tech/rest-api-roundtrip-with-springdoc-and-openapi-generator-30bd27ccf698) by [cloud @viadee](https://cloud-viadee.medium.com/) +- 2021-03-08 - [OpenAPI Generator 工具的躺坑尝试](https://blog.csdn.net/u013019701/article/details/114531975) by [独家雨天](https://blog.csdn.net/u013019701) at [CSDN官方博客](https://blog.csdn.net/) +- 2021-03-16 - [如何基于 Swagger 使用 OpenAPI Generator 生成 JMeter 脚本?](https://cloud.tencent.com/developer/article/1802704) by [高楼Zee](https://cloud.tencent.com/developer/user/5836255) at [腾讯云专栏](https://cloud.tencent.com/developer/column) +- 2021-03-24 - [openapi-generator-cli による TypeScript 型定義](https://zenn.dev/takepepe/articles/openapi-generator-cli-ts) by [Takefumi Yoshii](https://zenn.dev/takepepe) +- 2021-03-28 - [Trying out NestJS part 4: Generate Typescript clients from OpenAPI documents](https://dev.to/arnaudcortisse/trying-out-nestjs-part-4-generate-typescript-clients-from-openapi-documents-28mk) by [Arnaud Cortisse](https://dev.to/arnaudcortisse) +- 2021-03-31 - [Open API Server Implementation Using OpenAPI Generator](https://www.baeldung.com/java-openapi-generator-server) at [Baeldung](https://www.baeldung.com/) +- 2021-03-31 - [使用OpenAPI Generator實現Open API Server](https://www.1ju.org/article/java-openapi-generator-server) at [億聚網](https://www.1ju.org/) ## [6 - About Us](#table-of-contents) From 7a3b01a0f63e6b9a98962c189d7d985316544234 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 3 Apr 2021 05:28:25 +0200 Subject: [PATCH 15/99] Update usage.md with current CLI output (#9156) --- docs/usage.md | 120 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 38 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index a5719e27761..bfc2c4fa2a4 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -10,12 +10,13 @@ This page demonstrates navigating the options via CLI. Commands are presented he The `help` option lists all commands available to the CLI. -```bash +```text openapi-generator-cli help usage: openapi-generator-cli [] The most commonly used openapi-generator-cli commands are: author Utilities for authoring generators or customizing templates. + batch Generate code in batch via external configs. config-help Config help for chosen lang generate Generate code with the specified generator. help Display help information about openapi-generator @@ -30,26 +31,28 @@ command. ## version -The version command provides version information, returning either the semver version by default or the git sha when passed `--sha`. +The version command provides version information, returning either the [semver version](https://semver.org/) by default, the git commit sha when passed `--sha`, or verbose output when passed `--full`. -```bash +```text NAME - openapi-generator-cli version - Show version information + openapi-generator-cli version - Show version information used in tooling SYNOPSIS - openapi-generator-cli version [--sha] + openapi-generator-cli version [--full] [--sha] OPTIONS + --full + Full version details + --sha Git commit SHA version - ``` ## list The `list` command outputs a formatted list of every available generator. Pass the `-s/--short` option if you would like a CSV output for easy parsing. -```bash +```text openapi-generator-cli help list NAME openapi-generator-cli list - Lists the available generators @@ -66,7 +69,6 @@ OPTIONS -s, --short shortened output (suitable for scripting) - ``` Example: @@ -81,26 +83,49 @@ For the full list of generators, refer to the [Generators List](./generators.md) The `config-help` option provides details about -```bash +```text openapi-generator-cli help config-help NAME openapi-generator-cli config-help - Config help for chosen lang SYNOPSIS openapi-generator-cli config-help - [(-f | --format )] + [(-f | --format )] [--feature-set] + [--full-details] [(-g | --generator-name )] - [--markdown-header] [--named-header] - [(-o | --output )] + [--import-mappings] [--instantiation-types] + [--language-specific-primitive] [--markdown-header] [--named-header] + [(-o | --output )] [--reserved-words] OPTIONS -f , --format Write output files in the desired format. Options are 'text', 'markdown' or 'yamlsample'. Default is 'text'. + --feature-set + displays feature set as supported by the generator + + --full-details + displays CLI options as well as other configs/mappings (implies + --instantiation-types, --reserved-words, + --language-specific-primitives, --import-mappings, + --supporting-files) + -g , --generator-name generator to get config help for + --import-mappings + displays the default import mappings (types and aliases, and what + imports they will pull into the template) + + --instantiation-types + displays types used to instantiate simple type/alias names + + --language-specific-primitive + displays the language specific primitives (types which require no + additional imports, or which may conflict with user defined model + names) + --markdown-header When format=markdown, include this option to write out markdown headers (e.g. for docusaurus). @@ -112,6 +137,9 @@ OPTIONS Optionally write help to this location, otherwise default is standard output + --reserved-words + displays the reserved words which may result in renamed model or + property names ``` The option of note is `-g/--generator-name` (other options are exposed for tooling). @@ -153,7 +181,7 @@ To pass these go client generator-specific options to the `generate` command for The `meta` command creates a new Java class and template files, used for creating your own custom templates. -```bash +```text openapi-generator-cli help meta NAME openapi-generator-cli meta - MetaGenerator. Generator for creating a new @@ -161,11 +189,15 @@ NAME the language you specify, and includes default templates to include. SYNOPSIS - openapi-generator-cli meta [(-n | --name )] + openapi-generator-cli meta [(-l | --language )] + [(-n | --name )] [(-o | --output )] [(-p | --package )] [(-t | --type )] OPTIONS + -l , --language + the implementation language for the generator class + -n , --name the human-readable name of the generator @@ -186,7 +218,7 @@ For an in-depth example of using the `meta` command, see [Customization](./custo The `validate` command allows you to validate an input specification, optionally providing recommendations for error fixes or other improvements (if available). -```bash +```text openapi-generator-cli help validate NAME openapi-generator-cli validate - Validate specification @@ -200,7 +232,6 @@ OPTIONS location of the OpenAPI spec, as URL or file (required) --recommend - ``` Valid Spec Example (using [petstore-v3.0.yaml](https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml)) @@ -250,7 +281,7 @@ An example bash completion script can be found in the repo at [scripts/openapi-g The `generate` command is the workhorse of the generator toolset. As such, it has _many_ more options available than the previous commands. The abbreviated options are below, but you may expand the full descriptions. -```bash +```text openapi-generator-cli help generate NAME openapi-generator-cli generate - Generate code with the specified @@ -269,23 +300,24 @@ SYNOPSIS [--git-repo-id ] [--git-user-id ] [--global-property ...] [--group-id ] [--http-user-agent ] - (-i | --input-spec ) + [(-i | --input-spec )] [--ignore-file-override ] [--import-mappings ...] [--instantiation-types ...] [--invoker-package ] [--language-specific-primitives ...] - [--library ] [--log-to-stderr] [--minimal-update] + [--legacy-discriminator-behavior] [--library ] + [--log-to-stderr] [--minimal-update] [--model-name-prefix ] [--model-name-suffix ] [--model-package ] - [(-o | --output )] - [(-p | --additional-properties )...] + [(-o | --output )] [(-p | --additional-properties )...] [--package-name ] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] [(-s | --skip-overwrite)] [--server-variables ...] - [--skip-validate-spec] [--strict-spec ] + [--skip-operation-example] [--skip-validate-spec] + [--strict-spec ] [(-t